CoCoSDC for TRS-80 Color Computer part 6

See also: part 1part 2part 3part 4, part 5 and part 6.

When we last left off, I was discussing how the CoCo’s drive controller accessed multiple physical floppy drives by using drive select lines.

In the early days of CoCo disk drives, each drive was configured to respond to the same drive select (drive select 1, for instance). A special ribbon cable was used which flipped some wires at each connection, moving different drive select lines from the controller to the same (drive select 1, for instance) line of the drive. The first plug (for DRIVE 0) would have drive select 1 go to that drive’s drive select 1 pin. The second connector would have some wires twisted and flipped so drive select 2 would go to the drive’s drive select 1 pin. This was done so you did not have to configure each drive (by opening it up and moving a jumper connector) to respond to a different drive selects.

It was this method with a “4-drive cable” that CoCo users could plug up four of the same single-sided drives (all configured as drive 1s) and where they plugged in on the cable would determine which drive they responded to from Disk BASIC.

If you used a normal (and cheaper!) flat cable that passed all four drive select lines to each drive, then the drives had to be configured to know which select they should respond to. A double-sided drive had three drive select options (1, 2 or 3) and also responded to the side select line.

As previously discussed, the CoCoSDC hardware honors some of these drive/side select lines, but SDC-DOS’ disk routines bypass several places where normal Disk BASIC would be using them to pass along to the drive hardware. Because of this, the standard POKEs we used on real hardware to access the back sides of double-sided drives from BASIC do not work. While the hardware is willing the software is not.

But, if you were to boot the CoCo using standard Disk Extended Color BASIC, it will work. The CoCoSDC hardware honors the first two drive select lines and side select. The problem is, without SDC-DOS, you don’t have a way to mount disk images or enable/disable the virtual SD card drives when you want to access a physical drive.

SDC-DOS handles communication with the CoCoSDC firmware. That firmware handles the disk image files and making them look like physical sectors to whatever software is running on the CoCo (Disk BASIC, OS-9, copy protected software using its own disk routines, etc.).

Fortunately, CoCoSDC designer Darren Atkinson has provided a simple BASIC program that can send commands to the CoCoSDC firmware. It’s not as simple as typing in DRIVE0,”GAMES.DSK”,NEW but it does allow the major functions to be done when you are not running SDC.DOS. He shared the following:

Below is a BASIC program I sometimes use when SDC-DOS is not present. It’s a little slow and definitely more cumbersome than entering commands in SDC-DOS, but it gets the job done.  Save this program somewhere on your CF card or SCSI disk so you can run it when using RGB/HDB DOS.

The program is:

20 IF SL<1 OR SL>4 THEN 10
25 SL=SL-1
40 IF DR<>0 AND DR<>1 THEN 30
60 IF LEN(C$)<2 OR MID$(C$,2,1)<>":" THEN 50
70 C$=C$+CHR$(0):P=VARPTR(C$)
80 P=PEEK(P+2)*256+PEEK(P+3)
100 POKE &HFF40,67:POKE &HFF49,0
110 POKE &HFF4A,0:POKE &HFF48,DR+224
120 A=&HFF4A:B=&HFF4B
140 ST=PEEK(&HFF48):IF ST AND 1 THEN 140
 (I sure hope WordPress doesn’t eat the program listing again.)
He provides the following instructions:
When you run the program you will be asked for the MPI slot number containing the CoCo SDC (1-4).  You could edit line 10 to remove the INPUT statement and just set variable SL equal to the slot number.Next you will be asked for the SDC Drive Number (0 or 1) to which the command will be applied. Enter 0 for commands that don’t apply to a specific drive number, or just press ENTER.Finally you will be asked to enter a command string. Command strings begin with a letter and a colon (:). Immediately following the colon is a path name to a file or directory on the SD card.


Commands Available:

D:  set current directory on SD card
K:  create new directory
M:  mount or eject a disk image
N:  create (if necessary) and mount a DSK file
X:  delete a file or an empty directory


Set current directory to /GAMES/ARCADE


Mount Donkey Kong image in drive 0


Eject the disk image in drive 1


There is also a Rename command (R:).  That one requires a second null-terminated string (new leaf name) to be included in the 256 byte data block immediately following the first string.



This will be a key piece to handling RS-DOS doubled sided disks and backing up the individual sides to CoCoSDC disk images.

He also provided a way to call the additional DSKCON routines that SDC-DOS adds:

Here is a Basic subroutine which calls DSKCON to mount the file named DN$ into drive 1. Explanation of the code follows:

1000 DK=PEEK(&HC004)*256+PEEK(&HC005)
1010 SD$=”M:”+DN$+CHR$(0)
1020 P=VARPTR(SD$)
1030 POKE 238,PEEK(P+2):POKE 239,PEEK(P+3)
1040 POKE 234,&H85
1050 POKE 235,1
1060 EXEC DK
1070 ST=PEEK(240):RETURN

1000 assign DSKCON code address to variable DK
1010 build command string (SD$) to mount the file
1020 get pointer to the string descriptor (P)
1030 set DSKCON buffer to the command string data
1040 set DSCKON opcode to transmit a command string
1050 set DSKCON drive number to 1
1060 call DSKCON
1070 read DSKCON status result into ST and return

Meaning of bits in the status code:

Bit 7: set on any error.
Bit 5: set if file is already open in other drive.
Bit 4: set if file or directory was not found.
Bit 3: set on various hardware errors.
Bit 2: set if file or path name is invalid.

– Darren

You may be wondering why we might want to call SDC-DOS’s DSKCON directly. After all, if you are running SDC-DOS, you already have these commands. In my situation, I needed a way to detect if an image exist. There is no such call, so the only thing you can do is attempt to mount the image (DRIVE 0,”IMAGE.DSK”) and if it fails with a not found error, it doesn’t exist. On a CoCo 3, there is an ONERR command one could use to error trap that call so you might do something like this:

100 REM See if image DN$ exists.
110 ONERR GOTO 150
120 DRIVE 0,DN$
130 REM If here, we were able to mount, so it must exist.
140 PRINT "Image exists."
150 END
200 REM If here, we were not able to mount.
210 ONERR 'Turn off ONERR
220 PRINT "Error mounting image.":END

This works, but ONERR was only added in the CoCo 3’s Super Extended Color Basic. For the CoCo 1 and 2, this technique wouldn’t work. Thus, Darren provided me his DSKON routine so I could try to mount an image that way and read the returned status code.

Now I should have all the pieces I need to do what I want to do, which means this is a good place to say…

To be continued…

2 thoughts on “CoCoSDC for TRS-80 Color Computer part 6

    1. Allen Huffman Post author

      If I recall, this was part of me writing a disk backup system for archiving about 400 floppies I had. I needed to access floppies that were “double sided” but each looked like a single disk, as well as true double sided disks for OS-9. I also had some that were 40 track BASIC disks instead of 35, and some OS-9 disks I formatted to 42 tracks to get extra storage. Because of all this, no existing backup program would work.

      But during all this I found most of my disks were normal so I ended up just backing them up with BACKUP and some OS-9 stuff.

      I really think I’d like to finish my tool of if I ever get my real CoCo set back up where I can use it.


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.