Repository navigation
Conversation
…VDrive will share The GEOS installer and the TR block device each carry their own image geometry, BAM and directory code, and VDrive brings a third, more complete engine (40-track D64s, error bytes, BAM and directory growth for all three kinds, tested against c1541). Bring VDrive's engine in under Source/Teensy/DiskImage so the other two can move onto it. Nothing uses it yet. The copy differs from teensyrom-vdrive's d64/ only in what the firmware needs: SPDX lines, the placement macros moving into d64.h, and its three constant tables marked D64_FLASH so they land in PROGMEM rather than DTCM. DiskImage.h includes the code once for the single translation unit the firmware and the host harnesses build. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01X5t9wWXadFkQgKaCnjreF7
kfox
left a comment
There was a problem hiding this comment.
I reviewed the engine on the host. I built small C programs against DiskImage.h with fake reader/writer callbacks; I did not test it on hardware. Three defects and one design note are inline. None of them can happen on a board yet, since nothing calls the engine, but VDrive's write path will reach all of them.
…a 1541 does The allocator searched outward from the file's last sector and reported the disk full when it reached the end of the allocation order, so a file appended to after a scratch freed earlier tracks failed with blocks free. A hint on the directory track, D71 track 53 or D64 tracks 36-40 failed on its first new block. The search now restarts once from the start of the order before it reports FULL. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… write does When the last data sector or the directory entry could not be written, d64_close_write returned the error and left the entry unclosed with its blocks allocated. A new file or a copy left a splat file and leaked blocks, contrary to d64_copy's "nothing is left behind"; an append left the original file unclosed, so the next validate deleted all of it. The close now aborts the write as d64_write does on an error, which puts an appended file back. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… does d64_create with replace scratched the old file before writing the new one, so a replace that ran out of room lost the old file. The old entry is now kept in the write handle and scratched once the new file has closed; a write that fails leaves it as it was. Both files need room at once, so a replace can now fail on a nearly full disk where scratching first would have fit, which is also what a 1541 does. A locked file is refused before anything is written. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ritten d64_create now checks the lock itself instead of relying on the scratch it no longer does first; without the check the new file is written and the close fails with both files left on the disk. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… image It returned 0 both when the buffer was too small and when the header, directory or BAM could not be read, so a caller could only report an unreadable image as a buffer problem. It now returns the length, the new D64_E_BUF for a small buffer, or the read's own error (D64_E_IO, D64_E_LOOP for a looping directory chain). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
It skips d64_format's clearing pass, so on a used image the old data stays in every sector it does not write. The comment said what it writes but not that the caller must guarantee the rest is already zero. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks for the review, and for building against the engine on the host. The repros made each fix easy to pin down. All four points are addressed, each with a host test in
One more change you didn't raise: the
|
This is part 1 of a series of PRs to streamline and consolidate disk image (.d64/.d71/.d81) access, which will then be used to power the VDrive Special IO. This is a big hunk of code by itself, which is why I'm separating it out like this.
Rationale
The GEOS installer and the TR block device each carry their own image geometry, BAM and directory code, and VDrive brings a third, more complete engine (40-track D64s, error bytes, BAM and directory growth for all three kinds, tested against VICE's
c1541). This brings VDrive's engine in underSource/Teensy/DiskImage/so the other two can move onto it.State of affairs after this PR
Nothing uses it yet. The copy differs from teensyrom-vdrive's
d64/(commitb74ce37) only in what the firmware needs: SPDX lines, the placement macros moving intod64.h, and its three constant tables markedD64_FLASHso they land inPROGMEMrather than DTCM.DiskImage.hincludes the code once, for the single translation unit the firmware and the host harnesses build.Follow-up PRs move the block device, then the GEOS installer and boot-file reader, then the TR menu's D64/D71/D81 loading and directory listing onto it.
Memory
VD_COLD, whichDiskImage.hdefines asFLASHMEMon the firmware. None of it is reachable from the PHI2 ISR or an IO handler's cycle path.PROGMEM.mallocand adds no globals: all state lives in structs the caller owns, so it holds nothing in RAM1 or RAM2 between uses.DiskImage.hyet, so this PR doesn't change the TR or TR+ images. The RAM cost will show up in the follow-up PRs that call it, and those will report it.Docs
docs/Architecture/Disk-Images.md: what the engine is, where it came from, how a caller uses it, the size-to-format table, and its tests.docs/Architecture/Overview.md.Testing
Source/Teensy/tests/disk-image.test.js, which builds the engine with the firmware's warning flags as both C and C++. On a blank image of each kind it saves a file and reads it back, and it checks the size-to-format table.npm testpasses, and CI is green on both firmware builds (tr,tr-plus) and the tools job.Compatibility
No change to the remote protocol (
docs/ControlComms.md), the cartridge register map, the EEPROM settings or any timing.License
The engine is my own work from teensyrom-vdrive, which is MIT licensed. The files here carry
SPDX-License-Identifier: MIT.🤖 Generated with Claude Code