Catweasel AmigaOS driver development page!

by Ian Gledhill ()

This driver is modified from the original OS4 driver written by Kjetil Hvalstrand, based on Linux sources. catweasel.device is entirely under the GPL, source available on request.

Download the latest released version (31/03/2012) for AmigaOS 4 and MorphOS!
Download V1.02 of the preferences program for AmigaOS 4, including SID tests!
Download Vice-2.2 compiled for the Catweasel under AmigaOS 4 (Run from normal Vice-2.2 installation, select "Catweasel Mk3" from the SID menu)

Note: This is still in development phase. I am not responsible for anything that happens from running this software. I would also very much appreciate any reports of success or failure using any of this software, or any general comments of feature requests!

Note 2: These are drivers are not written by nor supported by Jens Schoenfeld, the creator of the Catweasel hardware. However I would like to offer my thanks to him for his provision of technical documents pertaining to this hardware.

Note 3: If you're using MorphOS, don't forget you need your filesystems installed! 68K versions of FastFileSystem, CrossDOSFileSystem, fs1541 etc. should work, remember to put them into L:!

NOW WITH SUPPORT FOR COPY-PROTECTED DISKS!!
Run your original Amiga games under AmigaOS 4! More info in the log below!

Regarding the advert at the top of the page...

I run a very small games company here in Aberystwyth, called Mutant Caterpillar Games.
We've just released an Android game for free called Numerix and it's rather funky, so please check it out and tell your friends!
I've also included a PayPal donate button in case anyone is feeling generous.
Please let me know if you use the program and how you find it - what should change, what works and what doesn't, that sort of thing. Got a particular format you want supported? Let me know. Need a version compiled for a platform? Same applies, ask me. It's written in ANSI C (POSIX) so is very portable.
Any feedback at all is useful!

Thanks!

Instructions for setting up your Catweasel

First, set up your Catweasel Mk4 as directed in the instruction manual. You shouldn't connect the Catweasel to the motherboard floppy interface, this isn't supported yet.

If you will be using SID chips, be absolutely sure that you have jumpered the SID sockets correctly. If you're not using any SID chips, don't worry about them.

The Catweasel should now be connected to your disk drive(s). Your Catweasel can have none, one or two disk drives. As with any other disk interface, unit 0 is the drive after the twist in the floppy cable (some modern cables only have two connectors, with a twist in the middle. This will work fine for unit 0). 3.5" floppy disk drives are jumpered to be unit 1 - putting the drive after the twist sets it to unit 0. If you are connecting a 5.25" drive, be sure that it is set to unit 1 (many drives do not have jumpers - these will almost certainly be wired to be unit 1 anyway). If you are connecting a 3" drive, it will be hard-wired to either unit 0 or unit 1, and the cable will not have a twist, so unit 0 may be unavailable but unit 1 will work.

Once the Catweasel is installed correctly, start up the computer. When the desktop has booted up, decompress the archive to RAM:, and drag the contents of the Catweasel directory to your boot drive (this will be some directories such as "devs" and "utilities").

Once the files are installed, go to your Prefs directory on your boot drive, and run the program called "Catweasel". This will allow you to tell the Catweasel what kind of devices are attached to your Catweasel. It is important that these are set correctly; usually you will want these set to 3.5" High Density drive or 5.25" High Density drive as these are by far the most common types, and are found as standard in IBM compatibles for many years. For almost all cases, you will not need to change the pin 34 function from the default.

You should also set here which SID sockets are occupied.

The hardware attached to the Catweasel

This tells the driver what kind of disk drive is attached for each unit.

Time for drive to step 1 track

This is the time taken for the stepping motor to move the head by one track. If this is set too low, disk operations may be unreliable. If set too high, performance will be lower than necessary. The usual default is 6mS, as this is standard for most drives. Some drives such as 3" Amstrad drives, however, require a longer stepping time. The defaults will normally work.

Function of Pin 34

The default of this will almost always be correct. If your drive misbehaves and thinks disks have been changed for no reason, you could try changing this setting.

Technical info:

Some early drives, notably 3" Amstrad drives and 40 track IBM compatible drives, use pin 34 for a "Ready" signal (RDY) which tells the controller that it is ok to write data (the pin is set logical low when the head is at the correct position and the spindle motor is operating at >85% speed). Other drives usually use pin 34 for a "Disk Change" (DSKCHG) signal, which goes logical low when a disk has been changed since the last access. This signal is updated when the drive is asked to do an operation such as a head step - this is why Amiga disk drives, and indeed, this Catweasel driver, "gronk" the disk drive: causing the head step updates the disk change signal and notifies the controller that a disk has been inserted or removed.

Note that on drives which use pin 34 for a RDY signal, the operating system cannot determine when a disk change has been made; in this case, when using a mounted device, you must execute a diskchange command: for instance (from a shell):

1.RAM Disk:> diskchange OS0:

Enable/Disable SID sockets

Use these cycle gadgets to tell the driver which SID socket has been occupied. This way, if you open unit 0 of catweaselsid.device, you will always get a SID as long as one is installed, whichever socket it is in. Having two SIDs will enable stereo SID support where the application supports this.

Included files

Mounting a device

Devices in AmigaOS and compatible systems are mounted by double-clicking on the icon in SYS:Storage/DOSDrivers for the appropriate device, or by typing "mount " from a Shell. Device names end in 0 for unit 0 drives (such as a normal 3.5" High Density drive at the end of the cable after the twist), or a '1' for unit 1 drives (such as a drive like this connected before the twist).

The following mountlists are included in the archive:

DeviceFormat
TD0:Amiga Double Density 880KB
TH0:Amiga High Density 1.76MB
PD0:MS-DOS Double Density 720KB
PH0:MS-DOS High Density 1.44MB
OD0:MS-DOS Double Density (5.25") 360KB
OH0:MS-DOS High Density (5.25") 1.2MB
OS0:MS-DOS Double Density (5.25") 320KB
CBM0:CBM 1541 (C64, VIC-20 etc., (Partial write support, requires cbm1541_fs.lha)
SAM0:MGT Sam Coupe (Currently Read Only, requires "samdos_fs.lha")

Dismounting a device

Devices can be dismounted from a shell by typing (for example):

1.RAM Disk:> dismount SAM0:

Note that the requires support in the filesystem! Many filesystem do not support this; if AmigaDOS returns an error saying "Invalid Packet Request", the file system does not support dismounting.

Running "Assing SAM0: dismount" will dismount the drive from the available devices, but does not close the device. You will therefore continue to hear the disk drives "gronking".

The catweasel.device support task

"catweasel.device", when it is opened, will start a similarly named task which governs disk changes. Every two seconds, the drives will seek (or "gronk") to check for a new disk. If a disk is inserted, the drive will not seek in this way.

When the device is closed, the support task will quit.

Reading and writing disk images with SuperDiskImage

SuperDiskImage is a graphical disk imaging program which can read and write disk images of many different formats.

To read a disk image from disk to a file:

  • Type in the image name into the image filename box.
  • Select the drive unit to use (0 or 1)
  • Select the format to use.
  • Set the tracks and sides to read if necessary (normally not necessary)
  • Click "Read Disk"
  • If the disk is of the correct format, the blocks will turn green as they are read from the disk. Once the disk has been read, the file will be saved out to the specified location. Note that if you have specified to only read a section of the disk, the image file contents will be updated rather than replaced. If a block cannot be read, either because the disk is bad, not present, or it is copy-protected, the block will turn red.

    To write a disk image from a file to a disk:

  • Type in the image name into the image filename box, or use the file requester gadget next to the box to select a file.
  • Select the drive unit to use (0 or 1)
  • Select the format to use.
  • Set the tracks and sides to write if necessary (normally not necessary)
  • Click "Write Disk"
  • The disk (or the selected part of the disk) will now be written to the disk. As each block is writtem the corresponding block will turn orange. SuperDiskImage will verify that a block has been successfully saved to disk after each write. If the verification fails, the block will turn red. SuperDiskImage will then retry the block twice. If after the third attempt, the block is still invalid, it will abort the disk writing. If you wish to skip a block, set the start block to the one after the problem one, but be warned your disk will be missing data! Once the block is written and verified, the block will turn green, and SuperDiskImage will continue to the next block.

    Show Disk Parameters (not implemented yet)

    Click on this to see the disk parameters for the currently selected format, i.e. block size, number of blocks, sides etc.

    Catweasel format cycler

    The formats which can be written will be available in the cycle gadget for the currently selected unit. If the format you wish to read or write isn't listed, ensure you have the correct unit selected. If the format still doesn't show, check your Catweasel preferences (SYS:Prefs/Catweasel).

    Available formats are:

    ID (Flags)Required HardwareFormatFormatted Space
    0 Any DS 80 Track 3.5" or 5.25" Amiga Double Density 880KB
    1 3.5" High Density Amiga High Density 1.76MB 1.76MB
    2 Any DS 3.5" MS-DOS Double Density 720KB 720KB
    3 3.5" High Density MS-DOS High Density 1.44MB 1.44MB
    9 Any DS 3.5" Apple Macintosh DS varispeed 800KB 800KB
    10 Any 3.5" Apple Macintosh DS varispeed 400KB 400KB
    15 Any DS 5.25" MS-DOS 40 Track DSDD 8 Sectors 320KB
    16 Any 5.25" Commodore 1541 (PET/C64/VIC-20/+4 etc.) 35 Track 190KB
    17 5.25" HD MS-DOS 80 Track DSDD 1.2MB 1.2MB
    18 Any DS 5.25" MS-DOS 40 Track DSDD 9 Sectors 360KB
    19 Any DS 80 Track 5.25" Amiga Double Density 880K 5.25" 880KB
    28 Any DS 3.5" 80 Track MGT Sam Coupé 800KB
    29 Any 5.25" Texas Instruments TI-99/4(a) 90KB
    30 Any 5.25" Atari 810 SSSD 90KB 90KB
    31 Any 5.25" Acorn BBC Micro 40 Track SSSD 100KB 100KB
    36 Any 80 Track 5.25" Acorn BBC Micro 80 Track SSSD 200KB 200KB
    37 Any 3.5" Acorn BBC Micro 40 Track SSSD 100KB 3.5" 100KB
    38 Any 3.5" Acorn BBC Micro 80 Track SSSD 200KB 3.5" 200KB
    39 Any 3.5" Sinclair Spectrum MGT +D 800KB 800KB
    40 Any 3.0" Amstrad CPC / Sinclair Spectrum +3 180KB
    41 Any 3.0" Tatung Einstein TC-01/TC-256 200KB
    42 Any 3.0" Amstrad PCW 8256/8512 180KB
    43 Any DS 3.5" Atari ST DSDD 720KB 720KB
    44 Any 3.5" Atari ST SSDD 360KB 360KB
    45 Any 5.25" Triumph-Adler Alphatronic PC 360KB
    46 Any DS 3.5" MS-DOS Double Density 640KB (8 sector) 640KB

    Setting AmigaOS 4 up for protected disks

    Using WHDLoad, you can now install protected disks! Most WHDLoad programs assume you're using trackdisk.device, though, as nothing else (until now!) could work! To prepare your system to do this:

  • Edit DEVS:NSDPatch.cfg
  • Add the following lines (adjusted for machinetype - look at other lines in the file for keywords):
    DEVICE trackdisk.device UNIT 0 MAPTODEVICE catweasel.device MAPTOUNIT 0 MACHINE=machinetype
    DEVICE trackdisk.device UNIT 1 MAPTODEVICE catweasel.device MAPTOUNIT 1 MACHINE=machinetype
  • Install NSDPatch if you haven't done so already. (Probably just a matter of copying NSDPatch to c: and running it directly after SetPatch in your s:startup-sequence)
  • Copy your SYS:Storage/DOSDrivers/TD0 to SYS:Storage/DOSDrivers/DF0 (or DEVS:DOSDrivers/DF0 if you're feeling brave)
  • Reboot
  • Your system is now ready to read copy-protected disks! A side-effect of this is that all trackdisk commands will now be sent to the Catweasel instead of trackdisk! This may break things, so if you need to stop redirecting trackdisk calls, comment out the line running NSDPatch in your S:Startup-sequence, or the added lines in DEVS:NSDPatch.cfg.

    Using WHDLoad

    This is the easy part! Just install WHDLoad as usual, downloaded from http://www.whdload.de. Now download your game installer, and (once you've made sure that DF0: is mounted), run the installer as normal. Your game should now install exactly as on a real Amiga! If you combine this with RunInUAE You can then run your Amiga game directly from the Workbench!

    Using catweasel.device

    To maintain compatibility with multidisk.device as used by earlier Catweasels on the Amiga, the same trackdisk commands will work with catweasel.device, and the flags are used in the same way. To tell the Catweasel which format to use, the device is opened with an identifier in the flags field, as seen in the table above.

    catweasel.device is commandset compatible with trackdisk.device, so programs written for the Amiga and which cleanly use trackdisk.device should also work with catweasel.device.

    Using catweaselsid.device

    "catweaselsid.device" is the interface to the SID chips. It requires catweasel.device to operate. Opening unit 0 will always open a SID, whichever socket it is in. Opening unit 1 will open the second SID chip. Once the SID chip is opened for access, programming the SID chip is the same as the Windows method of writing data, that is a stream of register followed by value. So, writing a stream in hex of:

    00 01 09 13

    would set register 0x00 to value 0x01, and register 0x09 to 0x13. In this way the SID can be programmed quickly and easily. Reading from the SID chip is done in a similar way, but the return value is put into the value part, i.e. reading the above would put the register 0x00 value into where "0x01" is.



    31/03/2012 When is a broken PC disk not broken...?

  • When it's not the format you think it is, of course. Seems that Wizardry IV on 3.5" disk is actually a 640K 8-sector disk. And there was me thinking the disk was broken all this time! Therefore, next time you're trying dump a PC Booter disk from the mid-80's, try the new 640K disk format.
  • Also updated this page with the flags fields for more formats.
  • I think this version will work on the Pegasos II - if it doesn't I'll upload a new version on Monday.
  • I've not updated the MOS version for a while - but the source is included, so feel free to try and compile it!
  • 08/09/2011 Oops.. wrong codebase...

  • My AmigaOne wasn't as up-to-date as I thought so I broke the Pegasos II code. Put the changes back into the current source, should work again now!
  • 06/09/2011 Changes to the disk detection..

  • The code for working out whether a disk was in or not was getting increasingly munged, causing the screen to go black in Update 3 as it would mis-report the presence of a disk on start-up, causing AOS to "display" a requester saying "No disk present in device TD0:" if it were mounted in DEVS:DOSDrivers/. Because of the changes, the old version is still here.

    19/11/2010 Silly bug in SuperDiskImage for MorphOS

  • Left a bit of work-around code from AROS in SuperDiskImage, resulting in too large an array of formats available. Sorted now (thanks Stefan for the heads-up!).

    18/11/2010 Catweasel.device now works under MorphOS!

  • The archive contains both versions! Tested on a Pegasos II, please let me know how you get on if you run the MorphOS version as it's very beta at the moment!
  • More bugs have been fixed also.
  • Fixed Pegasos II compatibility under AmigaOS 4.1!
  • 03/10/2010 More drive types - now supporting Amiga drives! Be sure to check your preferences as the settings may have changed!

  • Two more drive types added - 3.5" DD 80 track for Amiga (bog standard A500 drive) and 3.5" HD for Amiga (A4000 HD drive). I was going to try with a decased external Power Computing XL (HD) drive, but the connector is wrong for a standard floppy cable (upside-down). I don't know what will happen with an internal one! It should work by setting for a 3.5" Amiga HD though. Remember this is the drive type, not the disk type. Basically, if your floppy drive came out of an Amiga, not a PC, then you want one of these settings. However, there will be no diskchange! There is no way to read an Amiga diskchange signal on a Catweasel, so you must always execute a diskchange command whenever you switch disks (i.e. "Diskchange TD0:").
  • SuperDiskImage and Catweasel Preferences programs updated for new formats
  • More bug fixes!
  • 02/10/2010 Bugs fixed in disk detection!

  • Disk detection code is better now. This should hopefully fix people with black screens on rebooting! If you still get black screens, make sure you have no disks inserted otherwise there's probably a prompt in the background telling you it's a bad format!
  • 01/10/2010 New version uploaded!

  • First public version with RAWREAD support. I successfully installed Shadow of the Beast 2 with this version, from the original disks!
  • 30/09/2010 RAWREAD support for copy-protected disks! Added a little section above on how to do this.

  • You can now install Amiga games from original floppies! This morning I successfully installed Ork (Psygnosis) this way, despite it being totally non-standard disk format. Thanks again to Dámaso for helping with this by providing the NSDPatch info!
  • 26/09/2010 A donation!

  • Very many thanks to Dámaso for his very generous contribution! It'll help towards a 1571/1581 drive so I can add support for that too! :)
  • 25/09/2010 More bugs fixes and MS-DOS formatting!

  • Fixed: the motor would delay on starting, even if it was already running, making the C64 fs very slow. C64 writing now partially works - large files are only partially written.
  • Update: The change to do with CMD_CLEAR yesterday fixed formatting with MS-DOS disks!
  • 24/09/2010 Bugs fixes and MasonIcons added!

  • Thanks to Martin "Mason" Merz for some new icons!
  • Fixed: the write-behind cache writing code assumed the disk was double-sided! CBM 1541 filesystem can now write to disk!
  • Fixed: calling CMD_CLEAR would invalidate the write-behind cache before the data was written!
  • Problem: CBM 1541 filesystem now writes but access is very slow. Something to do with the motor being turned on or off.
  • 23/09/2010 First log entry:

    Created this page!