Commodore‎ > ‎C128‎ > ‎

JiffySoft 128

  History  

Due to the notoriously slow performance of the C1541 disk drive on the Commodore 64 computer, a company called CMD launched a very successful line of upgrade ROMs for Commodore computers and peripherals back in the 1980s which greatly increases disk access time.  This is the famous JiffyDOS. 

The Commodore 128 doesn't really need this when using devices designed for it.  The C128 supports "fast" serial communication, which uses hardware to transfer data on the serial bus (instead of software routines like on the VIC-20 and C64).  However, this requires a "fast" serial device, like the C1571 or C1581 disk drive.  Older devices, like the C1541, will use the "slow" serial routines (unless both the device and the C128 are upgraded with JiffyDOS ROMs).
 
 
  21st Century  

Recently new Commodore-compatible mass storage devices have become available.  Many of these support the same (software) protocols used by JiffyDOS.  Examples include SD2IEC and µIEC.  These devices are smaller, more reliable, and use less power than the traditional floppy disk drives. 

Unfortunately, none of these new devices (AFAIK) support "fast" serial communication.  This means these remarkable devices will operate at "slow" serial speeds unless you upgrade the ROMs in your Commodore 128, or...
 
 
  My Solution  

Another option is to use software on the C128 that communicates with the JiffyDOS protocol.  This allows an un-modified C128 to communicate at high speed with any device that supports JiffyDOS (either a classic disk drive upgraded with JiffyDOS ROMs, or a device that natively supports JiffyDOS like the uIEC).

This "software JiffyDOS" support has been developed for (at least) the VIC-20 and C64.  Recently I got a copy of the C64 version, but I didn't like the way it trashed registers, and according to C128 Alive! forum member Diddl, it does not support "sector loading."  This is kind of technical and explained later.  The important thing is I decided to write a version for the C128 and have success to report and share with you.
 
SJ128 is my implementation of the JiffyDOS protocol on the C128.  You can download the disk image and start using it with the BASIC command:
RUN "SJ128 INSTALL"
 
This gives you two install options (or quit).  Option one will install to a single region of RAM ($1700~1BFF).  Because the "application area" (region $1300~$1BFF) is often used by utility programs, a second option that uses less of the popular area is available.  Option two will install to RAM in two parts; first at $C00~$DFF and second at $1900~$1BFF.  Unfortunately both options use some part of the application area, but the second option leaves over 1kB available.
 
 
  VIC-20 Version  
  
A version of JiffySoft for the Commodore VIC-20 was developed by Diddl of the C128 Alive! ForumsVersion 6 (with improvements from my SJ128) is available for download. It has two binary files (for $0400 or $B000) and source code!  Diddl reports speed increase of 40%.
 
  
  Compatibility  
  
SJ128 tries to do it all.  It supports JiffyDOS protocol if the device connected to the C128 will accept it.  Failing that, it will use "fast" (hardware) serial protocol, if supported.  Finally it will use "slow" (software) serial protocol.  I've tested all 3 "modes" in VICE and on my C128.  The only problem is with VICE v2.0 in NTSC mode with JiffyDOS protocol (but it works fine in reality).
 
NOTE 1: SJ128 is software, which means that a program may overwrite the RAM where it is installed.  It will not work with all other software.  If option one doesn't work with a particular program, try option two.  But there is no gaurantee that will work either.  The nice thing about JiffyDOS ROMs is they are firmware; they can not be over-written and don't need to be installed.
 
NOTE 2: SJ128 is for the Commodore 128.  Also included on the disk image is "SJLOAD" which is for the C64 and was not written by me.  The source files for the C64 version are included on the disk image (or see this site).
 
NOTE 3: SJ128 works by changing vectors (in the $300 region of RAM) that are used by the KERNAL.  A program that bypasses the KERNAL Jump Table will not benefit.  Most programs use high-level routines (like Open, ChkIn, and Load) so they will work if they use the KERNAL Jump Table, but will not have Jiffy speed if they call low-level routines like Listen and Acptr (because there are no vectors).  In fact, a program that mixes high-level and low-level KERNAL calls may crash! 
 
NOTE 4: After installing SJ128, you can revert to the orignal ROM routines by pressing STOP + RESTORE or calling the KERNAL routine RESTOR ($FF8A).
 
 
 
  Performance  
 
I've tested SJ128 on a real (NTSC) Commodore 128 with a C1571 disk drive (no JiffyDOS) and a uIEC/SD (with JiffyDOS).  I experienced no problems.  I also tested it with VICE v2.0 and sometimes directory listings would be garbled.  My theory is the JiffyDOS protocol is extremely critical with an NTSC machine and works fine on a real C128 which has some delay on the serial bus while VICE assumes data travels without delay.
 
On the disk image is a file "CRCCHECK" that is 197 blocks in size.  It takes less than 8 seconds to LOAD with SJ128 from a uIEC.  It takes about 9 seconds to VERIFY with SJ128 from a uIEC.  However SAVING is not impressive.  It takes almost 45 seconds to SAVE with SJ128 to a uIEC.  Because of my unreliable floppy disks / drive, I don't have times for a real C1571, but in VICE it takes less than 20 seconds to load/verify using optimal sector interleave (emulated C1541+JiffyDOS) and about 45 seconds to SAVE.
 
 
  Source Code  
 
I'm also providing the source code to SJ128 so anyone can improve it.  One nice option would be to relocate most of the code to high RAM (so it would be unlikely to be over-written) with a small "stub" in low RAM (for calling KERNAL ROM routines).
 
The source code was compiled using "xa" (by Andre Fachat, available here) on a Windows machine; also included are Windows' batch files to call xa and assemble 3 versions.  One version is "debug" and is a single segment starting at $1300 without install option.  Another version is "single" which adds an install routine along with a single segment SJ128 at $1700~$1BFF.  The third version "double" has an install routine with the code split into two segments ($C00~$DFF, $1900~$1BFF).
 
Aside from the trivial version file (debug, single, or double), the source code is split into two files, "core" and "high".  The core contains I/O, RAM, and ROM definitions along with low-level serial routines like Listen, Talk, Unlisten, etc.  The "high" code consists of routines like ChkIn, Open, Load, etc.  BONUS: Some of the patches that Commodore made to the KERNAL ROMs are included for those (like me) that have the original buggy ROMs.
 
When reading data from a device, JiffyDOS supports two modes of communication.  One is "byte" mode and the other is "sector" mode.  Byte-mode is used when reading the error channel, when a program reads data from a sequential data file, or when reading the directory.  Sector-mode is only used during LOAD/VERIFY (not directory).  In this case up to 254 data bytes are received from the JiffyDOS device in a loop (much faster than byte-mode).  NOTE: The C64 version (not by me, but included on the disk image) does not support sector-mode according to Diddl (so it may be much slower).
 
 
  How it Works  
 
Here is a description of how the JiffyDOS protocol works for those who don't want to read the source code.  When the C128 wants to communicate with a device on the serial bus, it starts by sending a command.  Normally this is sent like a standard/slow data byte with the exception that the /ATN line is activated first ("active" means it is pulled to 0 volts).
Diagram of standard (slow) serial bus command transmission on a Commodore computer.
But with SJ128 installed (or JiffyDOS ROMs), the C128 will insert a long delay before sending the last data bit of the command.  If the device on the serial bus toggles the DATA line during this delay, the C128 will assume it is talking to a JiffyDOS device and use the "jiffy protocol" for sending and receiving normal (not command) bytes when communicating with that particular device.
Diagram of JiffyDOS serial bus command transmission on a Commodore computer.
 
Now that we know how the C128 recognizes JiffyDOS devices, let's compare serial bus protocols.  First we have standard (slow) bus protocol.
Diagram of standard(slow) timing for Commodore serial bus transmission.
 
Notice the standard protocol takes 800 micro seconds (and that is neglecting set-up time).  Next is a diagram for trasmission with the "Jiffy protocol" (used to SAVE or send filename during Open command).
Diagram of Commodore transmiting to JiffyDOS device over serial bus.
Finally is a diagram to read from a JiffyDOS device.  This is arguably the most important as it is used to read data from the device.
Diagram of Commodore receiving from JiffyDOS device over serial bus.
It should be easy to see that JiffyDOS protocol is over 10x faster than standard (slow) serial bus protocol.  The receive protcol works good most of the time, and even better with LOAD / VERIFY (which uses a special loop).  The transmit protocol, although 10x faster in theory, can only send 1 byte every 8 raster (1 byte per 504 microseconds) in reality.  This is because the receiver is very slow to accept data (as I've tested with emulated C1541).  The C1571 and C1581 operate at double speed (2MHz instead of 1MHz) and so they may respond faster (not yet tested by me).
 
 
  Sector Interleave  
 
When using a modern mass-storage device (like the uIEC), the sector interleave of a disk image is not important for LOAD/SAVE/VERIFY times.  But when using SJ128 with a JiffyDOS disk device (C1541, C1571, maybe FD-2000, CMD-HD, etc.), the sector interleave is very important.
 
Sector interleave is the number of sectors after the current sector to find the next sector.  For example, with a sector interleave of 10, the sequence of sectors loaded could be 0, 10, 20, 9, 19, 8, 18, etc.  In this example, 3 sectors would be loaded in the first rotation of the disk, 2 sectors in the second rotation, 2 sectors in the third rotation, etc.
 
Unfortunately, many programs designed to create disk images (or copy real disks) use a sector interleave of 1.  In this case sectors would be loaded as 0, 1, 2, 3, 4, 5, etc.  However a real C1541 disk drive (for example) can not read and transmit that much data (all 21 sectors) in one revolution.  So instead a real C1541 (with JiffyDOS) would transimit only 1 sector per revolution in this case.  This means instead of 3 or 2 sectors per revolution, only 1 sector gets loaded.  The result is slow performance!
 
On the C128, I've found that a sector interleave of 9 works best with SJ128 and a (floppy disk) JiffyDOS device.  Other devices will probably need a different value.  Anyway, if a program loads slowly from a JiffyDOS device when using SJ128, the problem may be a "bad" sector interleave; anything less than 9 will make it very slow, more than 9 will make it only a little slow.  This value is for 5.25 inch floppies; I don't have any other "real" disk devices.
 

© H2Obsession, 2009, 2010
Comments