Re: New firmware for PLC TIB DD-001 3.5" drive

From: Steve Gray <sjgray_at_rogers.com>
Date: Tue, 15 Aug 2023 17:02:48 +0000 (UTC)
Message-ID: <140216287.1943210.1692118968788_at_mail.yahoo.com>
 Very nice!

    On Tuesday, August 15, 2023 at 11:51:53 a.m. EDT, Maciej Witkowiak <ytm_at_elysium.pl> wrote:  
 
 Hi
TLDR
I prepared a new firmware for TIB DD-001 that uses standard FAT12 format on DD 720K floppies. So PRG files can be exchanged through 3,5" floppies just like with SD2IEC or Tapecart through SD cards. You can find the code here: https://github.com/ytmytm/TIB-001-Cart/tree/master/src
To quickly remind you what it is about: DD-001 was a 3,5" standard PC floppy drive connected via cartridge interface to a C64.There was a whole thread here about TIB DD-001 drive back in 2018: http://www.softwolves.com/arkiv/cbm-hackers/26/26957.htmlA more comprehensive introduction can be found here: http://news.ide64.org/2018/11/floppy-drive-tib-plc-dd-001-drive-2001.html

Few months ago I got a clone of that cartridge and I was finally able to play with it.

ORIGINAL FIRMWARE / BOOT DISK
First, I dumped the files from the original tool/demo disk image and stored them here: https://github.com/ytmytm/PyFAT12-DD-001
The original firmware can read and write FAT12: DD 720K, with 2 FATs, 112 root dir entries, 2 sectors per cluster (1K allocation unit). Windows 2000 on my old PC uses this as the default format for 720K. For mkfs.vfat under Linux these options can be passed explicitly.
Both DOS and Linux need valid information in the boot sector to decide about disk format: cluster size, number of FATs, root directory size etc. However the tool disk image itself had some junk data in the boot sector. For TIB DD-001 this was all hardcoded in the ROM. Once I supplied this information within the disk image, I was able to mount the image in Linux and read the files.The format tool provided on the tool disk will create floppies that you can read and write on a PC, only the tool disk image was broken.

The files were stored in FAT12 format with one important distinction - the load address was stored inside the directory entry, in one of the timestamp fields, instead of the first two bytes of the data stream. It effectively means that the data exchange was difficult - you can't just copy some PRG files from a PC to a floppy and load them on your C64.
The original code is a mixture of clever (I especially like their solution for handling timeouts with timer NMI and stack pointer manipulation) with incompetent.There is a jump table that was supposed to be used by user programs, but it's not really useful. TIB programmers forgot to use that jump table anyway.
MEDIA
The cartridge I have is a clone of the original one. The drive has to be connected with a straight ribbon cable (or to the connector before the twist for 2-drive cable). 5V power for the drive comes from an USB charger.I used a standard PC 3,5" HD drive and some HD floppies. I had to cover their HD holes to make DD format work. I own only one true DD floppy and that one works as well.
NEW FIRMWARE
I chose to clone Steve Gray's cartridge project for hardware part because of jumpers he added that would possibly allow us to use two drives.I started with the original firmware disassembly done by Ruud Baltissen: http://www.softwolves.com/arkiv/cbm-hackers/28/28457.html

Thank you both very much!
The binaries for original ROM and some tools can be rebuilt and checked against original dumps from a branch: https://github.com/ytmytm/TIB-001-Cart/tree/dd001-rom-v1.1/src with make regress

The new firmware stays on the master branch: https://github.com/ytmytm/TIB-001-Cart/tree/master/src

The changes I made to the master branch include:
- most important one: load address, like in CBM DOS, comes from the first two bytes of file - just copy PRG file and it will work- device number configurable during ROM assembly (default is now 7, because original 9 was a very poor choice)
- corrected handling of disk commands so R(ename), S(cratch), N(ew) work both via OPEN15,7,15,"...." and OPEN15,7,15:PRINT#15,"..."- changed disk directory format to match CBM standard when you LOAD"$",7 and LIST it- actually allow to load the directory like a BASIC program- after reset there is a brief pause after which ROM tries to load and run BOOT.PRG
- several optimizations, removed unused code - also from the tools- GEOS macros (LoadW, MoveW, PushW/PopW) to make the code easier to read- LOAD/SAVE will show start/end address, just like Action Replay loader- DOS wedge adapted into ROM from 1541 demo disk; with _at_$, _at_, /, ^, % commands
This file browser: https://commodore.software/downloads/download/29-disk-menus/1140-cbm-filebrowser-v1-6 can be used as BOOT.PRGIt's simple but still faster than typing commands. It works because it just loads '$' into memory and parses the result in place.
There is still some unused space left in the ROM. Future improvements could include support for:- directories- FAT12 format with 1 sector cluster size (3 sectors for FAT)- two drives
A GEOS disk driver could use this as a block storage device without care about FAT format.
Long DOS filenames or OPEN/GET#/INPUT#/PRINT# support for files is probably too much to ask from an 8K ROM without extra RAM.
The firmware still needs a lot of cleanups. It is totally not clear which variables are local for current routine and which ones are global. Resolving that would reduce allocation on zero page and within $02xx/$03xx temporary space.

But it is already good enough as a loader for one-file programs with easy (assuming you still have 3,5" drive in your PC) data exchange.
ytm
  
Received on 2023-08-15 20:00:08

Archive generated by hypermail 2.3.0.