Skip to content

GeoRAM IO handler for GEOS 64, sharing the REU's RAM bank code - #61

Merged
SensoriumEmbedded merged 15 commits into
SensoriumEmbedded:mainfrom
kfox:georam
Oct 26, 2026
Merged

SensoriumEmbedded merged 15 commits into
SensoriumEmbedded:mainfrom
kfox:georam

Conversation

@kfox

@kfox kfox commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Part of the GEOS 64 package (#61, #66, #67, #69, #70; #64 is separate). Adds a Berkeley Softworks geoRAM as a Special IO handler. GEOS 64 runs under this handler: the USB mouse (#66) and the TR block device (#69) put their registers in the IO page it leaves free.

  • Shared RAM bank code (RAMBanks.c): the REU's 8K bank allocation, image preload and numbered button save move out of IOH_REU.c so GeoRAM can use them. The REU keeps its own bank array and count, and its saves still go to the next free reuNNN, now written in whole 8K banks instead of a byte at a time. A failed write is now reported instead of acked with the LED.
  • IOH_GeoRAM:
    • A 256-byte window at $DE00 onto the page selected by the write-only $DFFE (page) and $DFFF (16K block) registers, decoded across $DF80–$DFFF as VICE does. $DF00–$DF7F stays free.
    • 128K to 512K, as much as fits beside a loaded crt.
    • Preloads SD:/georam.ram. The special button saves back to georam.ram through a temporary file, keeping the previous save as georam.bak.
    • No DMA. It is freed along with the REU wherever the menu reclaims RAM.

GeoRAM is the last manually selectable handler (LastSelectableIOH moves to it), so every handler number already saved in EEPROM keeps its meaning.

Tested on a TR+ in an NTSC C64, and in PAL through a VIC-II Kawari:

  • Button save replaces georam.ram and keeps the previous one as georam.bak; a first-ever save creates georam.ram; with only georam.bak and a stale georam.tmp on the card, .bak survives and a new georam.ram is written.
  • Relaunch preloads the saved image (NTSC and PAL).
  • Save with the card out fails without touching the files on the card; preload with no card reports "Not found!" and GeoRAM still holds data.
  • On an original TR in an NTSC C64: GEOS 64 runs under GeoRAM, and a file duplicated on the DeskTop survives a reset and relaunch.
  • REU regression: preload path, numbered saves (reu001, reu002, ...), and a stash/fetch from BASIC.
  • Freezers with the REU (Super Snapshot v5 NTSC, Final Cartridge III 101%): a byte stashed in the REU from BASIC reads back after a freeze and return.
  • On a TR+ in a C128 in 128 mode (BASIC 7.0, GeoRAM left running through a reset): writes to pages in block 0 and to the last page of block 31 read back after switching between them.
  • Earlier, on a TR+ in a C128 in C64 mode: a write and read-back of every page, and the same test program against VICE's 512K geoRAM.

Not run: GeoRAM beside a crt.

kfox added 9 commits October 15, 2026 14:31
Moves the RAM1/RAM2 8K bank allocator, the image preload and the numbered
button save out of IOH_REU.c into RAMBanks.c, so the GeoRAM handler can
use the same code. The REU keeps its own bank array and count: SerUSBIO's
busy check reads NumREU_Banks to mean the REU's DMA is live, which a
GeoRAM must not trip. Behavior is unchanged except that the save writes
whole banks instead of a byte at a time.
A Berkeley Softworks geoRAM: the $DE00 page window onto RAM banks from
RAMBanks.c, with the page ($DFFE) and 16K block ($DFFF) registers
decoded across $DF80-$DFFF the way VICE does, leaving $DF00-$DF7F
free. No DMA, so it is in every full build, TR and TR+, and serves C64
and C128 mode alike. Up to 512K, as much as fits beside a loaded crt;
preloads SD:/georam.ram, and the special button saves the next free
georamNNN.ram. Freed with the REU wherever the menu reclaims RAM.
A short write (card full, drive pulled) printed "Saved" and flashed the
save LED. Load stops at a read error rather than adding -1 to its count.
Placed before Debug it moved Debug's number, and that number is what
eepAdNextIOHndlr stores, so a board saved with Debug as its default came
up on GeoRAM. After Debug, with LastSelectableIOH moved to it, every
selectable handler keeps the number it had.
PanykSystem pushed a commit to PanykSystem/TeensyROM that referenced this pull request Oct 15, 2026
@kfox
kfox marked this pull request as ready for review October 21, 2026 14:47

@SensoriumEmbedded SensoriumEmbedded left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you Kelly for the GEOS64 implementation, this is exciting! :)

I reviewed the whole GEOS set merged onto current main (57a9d76) in the order you suggested, each PR on top of the one before it, and built both targets at every step. The note on each PR covers only that PR's own changes. As always, feel free to push back on anything that's inappropriate or would take significant memory/code to resolve.

Memory: this adds 512 B of RAM1 variables and 576 B of ITCM code to the main image on both the TR and the TR+. Free-for-locals goes from 80,700 to 80,188 on the TR+ and from 127,644 to 127,132 on the TR. MinimalBoot and the extension image are unchanged. One improvement:

  • Drop GeoRAM_NoRAM (IOH_GeoRAM.c:38): 256 B of DTCM. It's never read: IO1Hndlr_GeoRAM returns whenever there are no banks, and the handler only becomes current after its init has selected a page.

One thing to look at before merging:

1. A saved GeoRAM never comes back (IOH_GeoRAM.c:25, :63)

The button save goes through SaveRAMBanks's numbered naming, so it writes georam000.ram, georam001.ram and so on. The preload always reads georam.ram. The REU's preload file is a setting, but GeoRAM has no way to point at the saved file. So a GEOS RAM disk saved with the button is never loaded again unless the user renames the file on a computer.

Suggested fix: save over georam.ram, keeping the previous one as a backup if you like. Or preload the highest-numbered georamNNN.ram when there is one.

Hardware testing still to do: for one of us to possibly get to before release, not gates, and anything I noted that isn't listed is covered by your follow-ups or fine as it is

Your test program covers the 512K sizing, the block probe, every page and the register mirror, on a TR+ in C64 mode and in VICE.

  • GeoRAM under GEOS itself, with GEOS's own geoRAM RAM disk
  • a plain TR
  • a C128 in 128 mode
  • GeoRAM alongside a generic crt, where it gets less than 512K
  • a button save followed by a relaunch (after fix 1)
  • a preload with no SD card in the slot
  • the REU now that its bank code has moved: a preload, a button save, and the freezer + REU modes (SSv5, Retro Replay, FC3 1.01)
  • a downgrade with GeoRAM selected as Special IO: the handler numbers after it shift
  • PAL

Thank you!

@kfox
kfox marked this pull request as draft October 23, 2026 00:06
kfox added 4 commits October 22, 2026 19:17
GeoRAM_NoRAM was never read: the IO handlers return while there are
no banks. Init now points the window at the first page before it
publishes the bank count, so that stays true without it; the two are
volatile so the stores keep that order.
…oram.bak

The button saved to the REU's numbered names (georam000.ram, ...), but
preload reads only georam.ram, so a saved GeoRAM never came back. The
new image is written to georam.tmp first and renamed into place only
after the write succeeds. The REU keeps its numbered saves.
…nd puts it back if the save cannot take its place

If the last rename failed, georam.ram was gone: the next session preloaded
nothing, and saving that blank RAM removed georam.bak, the last good image.
… running handler's memory

A launch is accepted while a handler is busy. One naming a TR menu path that
does not exist returned after the CRT chips, REU, GeoRAM and SwiftLink
buffers were freed, without resetting to the menu, leaving the running
program on freed memory.
@kfox kfox changed the title GeoRAM IO handler, sharing the REU's RAM bank code GeoRAM IO handler for GEOS 64, sharing the REU's RAM bank code Oct 26, 2026
kfox added 2 commits October 25, 2026 19:26
# Conflicts:
#	Source/Teensy/MinimalBoot/Common/IO_Handlers/IOH_REU.c
#	Source/Teensy/RemoteControl.ino
@kfox

kfox commented Oct 26, 2026

Copy link
Copy Markdown
Contributor Author

Thank you for reviewing the whole GEOS stack this carefully, and for the build at every step!

I've merged current main (5f16876) into this PR and carried it up through #70, so all six merge cleanly again. Main had already made the same remote-launch fix this PR carried (find the TR menu target before freeing anything), so I took main's version and added FreeGeoRAM() beside FreeREU().

Memory: across the whole stack, free-for-locals in the main image now drops 768 B on both boards (TR 123,548 to 122,780, TR+ 80,700 to 79,932), so the TR no longer crosses the 4 KiB alignment step. On this PR:

  • GeoRAM_NoRAM is gone.

1. A saved GeoRAM never comes back

Fixed: the button save now writes georam.tmp, moves the previous georam.ram to georam.bak, then renames the new one into place. If that rename fails, the old file is put back. The REU keeps its numbered saves.

Hardware testing

  • GeoRAM under GEOS with its RAM disk: this can't run as shipped. CONFIGURE probes the IEC bus, which hangs with no drive, so GEOS 64 launches from the TR+ with the USB mouse, no disk drive #70 keeps GEOS from running it and GEOS never uses GeoRAM as a RAM disk. In this stack, GeoRAM is there to host the mouse and block device registers. GeoRAM itself is covered by BASIC page reads and writes, and by save and relaunch.
  • Done:
    • a plain TR;
    • a C128 in 128 mode;
    • a button save followed by a relaunch (NTSC and PAL);
    • a preload with no SD card in the slot;
    • the REU after the move: preload, numbered saves, a stash/fetch from BASIC;
    • Super Snapshot v5 and FC3 101% with the REU, a stash surviving a freeze and return. I didn't have an NTSC Retro Replay image;
    • PAL.
  • Not run: GeoRAM beside a generic crt, and a downgrade with GeoRAM selected.

One unrelated thing I hit on main itself: tests/easyflash.test.js fails on macOS on Apple silicon, because easyflash-harness.cpp:43 asserts that mmap returns 0x20200000, an address macOS there won't map.

@kfox
kfox marked this pull request as ready for review October 26, 2026 03:11
@SensoriumEmbedded
SensoriumEmbedded merged commit f155946 into SensoriumEmbedded:main Oct 26, 2026
4 checks passed
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.

2 participants