Skip to content

GEOS on the TR+'s REU: Special IO "REU+USB Mouse/Disk" - #81

Open
kfox wants to merge 16 commits into
SensoriumEmbedded:mainfrom
kfox:geos-reu
Open

kfox wants to merge 16 commits into
SensoriumEmbedded:mainfrom
kfox:geos-reu

Conversation

@kfox

@kfox kfox commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

GEOS 64 and GEOS 128 run with the TR+'s REU as their RAM expansion, found and set up by GEOS's own CONFIGURE, with the TR still drive A and no IEC drive.

What the user does. On a TR+, set Special IO to REU+USB Mouse/Disk in Settings, then pick GEOS 64 or GEOS 128 as before. With any other Special IO setting GEOS runs with GeoRAM, as it does now.

How it works

  • A new TR+ Special IO handler, REU+USB Mouse/Disk, keeps the REU at $DF00 and moves the USB mouse and block device registers to $DE00. Its unused REU registers read $FF, as a 1764's do, so TRB at $DF10 tells the two layouts apart.
  • The TR disk driver, the mouse driver and the GEOS 128 boot ROM find their page: the drivers check TRB at $DF10, then $DE10. The boot ROM's page is written in by the firmware at launch.
  • The -TR copy runs the stock CONFIGURE again. Its drive probe is patched to report the TR as a 1581 at device 8, and its 1581 driver record gets the TR transport. Copies made before this change, where CONFIGURE was put aside, are set up the same way. Any other CONFIG auto-exec, or a CONFIGURE not laid out like the stock one, is still kept from running.
  • A copy's TR USB MOUSE driver is brought up to date in place at each launch, since an older one looks for the mouse where the REU now sits. One that takes a different number of blocks is refused with "its TR USB MOUSE is an old one; delete this copy".
  • Docs:
    • docs/TR_Block_Device.md describes the second page.
    • A new docs/GEOS128_Usage.md covers GEOS 128.
    • docs/GEOS64_Usage.md and the GEOS 128 page share a "RAM expansion: GeoRAM or REU" section, which says which Special IO gives which RAM expansion on which board and recommends the REU on a TR+.
    • docs/General_Usage.md lists GeoRAM, 512KB REU and REU+USB Mouse/Disk under Special IO.
    • README.md links the GEOS 128 page.

Verified on hardware on a TR+ in an NTSC C128, with no IEC drive:

  • GEOS 64 in C64 mode on the REU: CONFIGURE reports 512K (ramExpSize = 8), drive A is the TR, DeskTop up.
  • GEOS 128 on the REU in 40 and in 80 columns, with the USB mouse; a file duplicated on the DeskTop.
  • GEOS 64 and GEOS 128 on GeoRAM still reach the DeskTop, and the duplicated file is there after relaunching.
  • NTSC read margin, per Constraints.md: a Dbg_SerTimChg build with a C64-mode loop reading the REU's address and length registers back, $DF10-$DF1F, and the TR page's TRM/TRB, 8 s at each step (1,400 to 5,100 rounds a second, by layout), while nS_PLAprop is raised. From the default of 150, the stock 512KB REU handler first fails at 260, this handler at 250 (one error at 240), and GeoRAM's TR page, as shipped, at 240.

Host tests. The disk and mouse drivers run on the 6502 emulator against a modeled REU and GeoRAM page, and the boot ROM with either page. The disk patcher tests cover the probe and driver records, the retyping, a copy set up by an earlier release, and the mouse refresh and its refusals. New harnesses cover the handler's IO2 page (the REU's registers, $FF across the rest of each 32 bytes, nothing without an REU) and which handler a GEOS launch runs under; each fails with the code it covers removed. npm test passes 337 of 337 on macOS, and under GCC in a linux/amd64 node:24 container 295 pass with 8 skipped for tools and disks it lacks. The firmware builds for TR and TR+ in the same container.

Reviewed at medium per change, with each review's fix commit at low, then a final medium pass over the branch, then a pass by Auditor, Adversary, Steward and Pragmatist lanes per the guidance in #79, whose fix commits got a low review. The docs commit was reviewed at low against the code; it changes no code (git diff c9fceda3 5c8de5b7 -- ':!*.md' is empty).

Memory, from CI's build of this head against main's: RAM1 code grows 832 B on the TR+, for the new handler's IO2 path, which the bus-cycle interrupt calls; it shrinks 64 B on the TR. RAM1 variables, free-for-locals and RAM2 are unchanged.

kfox added 15 commits October 29, 2026 19:54
… beside an REU

Under an REU the registers move to $DE00, since the REU's own repeat
across $DF00-$DFFF. A copy of the driver lives on the user's disk, in
CONFIGURE's 1581 driver, and outlives a change of Special IO, so it
looks for the TRB id at $DF10 and then $DE10 on every transfer instead
of being told the page when it is installed. $DF10 comes first because
$DE10 is GeoRAM's window, which can hold any bytes; an REU's unused
registers read $FF there.
…r beside an REU

Beside an REU, $DF03-$DF05 are its address registers, which hold
whatever the last transfer left and so can read "TRM". The block
device's TRB id at $DF10 picks the page instead: an REU's unused
registers read $FF there, and GeoRAM's window at $DE10 is never asked.
… launch gives it

The boot ROM is built at every launch, which knows which handler it
starts, so the firmware writes the page into the ROM instead of the ROM
searching for it: a glitch-safe search does not fit in the one page the
cold start copies. geos128boot.mjs assembles the ROM at two pages and
lists the bytes that move, as trdrive.py does for relocations. The
launch still asks for the page beside GeoRAM.
…R as drive A

CONFIGURE is what finds an REU and sets GEOS up to use it, so it has to
run. Its drive-type probe now answers a 1581 at device 8 and nothing
elsewhere, and the 1581 driver it installs for drive A, its record 4,
gets the TR transport the boot image already has.

The stock file is known by the target's name for it and by the probe in
record 0, so a copy made before this, where CONFIGURE was retyped, is set
up the same way. Anything else named CONFIG is still kept from running,
including a CONFIGURE whose records are not laid out as the stock one.

The synthetic test disk has one directory sector; the old CONFIGURE test
put a ninth file past it, so its check that CONFIGURE.DOC stays as it
was looked at a slot no directory held.
The copy outlives the firmware that made it, and a mouse driver from
before the REU route reads $DF03 for its ID, which beside an REU is an
address register. The driver is rewritten in place over its own blocks;
one taking another number of blocks is refused with a message to delete
the copy, since growing it means allocating on the user's disk.
The REU answers at $DF00 as before, and the USB mouse and block device
move to IO1, the page an REU leaves free. A GEOS launch takes this
handler when it is the Special IO setting, and GeoRAM otherwise, and
builds the GEOS 128 boot ROM for the page that handler puts the
registers on.

Beside the REU, $DF0B-$DF1F read $FF, as a 1764's unused registers do,
so the TRB id the GEOS drivers look for at $DF10 cannot appear there.
…d not at all without an REU

The TR's GEOS drivers decide which page holds the block device by what $DF10 reads, and no test ran IO2Hndlr_REU_TRPage itself: dropping its $FF answer, its bank check or its 32-byte mirror left the suite green.
…osen for

Both the C128 boot ROM's register page and the handler come from GeosIOHandler(), and no test held either: dropping IOHandlerSelectInit's GEOS branch puts GEOS under the item's GeoRAM while the boot ROM looks beside the REU, and the suite stayed green.
Giving GeosIsDriverAt and GeosReplaceTransport a second caller took them out of their inlined callers and into ITCM, 334 bytes on both TR and TR+, and the probe patterns and CONFIGURE names landed in DTCM. The build's memory report showed it; marking them FLASHMEM and PROGMEM, with GeosFindOnce and GeosBytesInBlock beside them, returns 320 bytes of RAM1 code on each target and leaves the TR's below where it was before the REU change.
@kfox
kfox marked this pull request as draft October 30, 2026 04:05
@kfox
kfox marked this pull request as ready for review October 30, 2026 04:08
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