CMDR-DOS is an open source 65c02 reimplementation of Commodore DOS, the OS and disk API of Commodore 8 bit disk drives (like the 1541). It works on FAT32 filesystems (32 MB to 2 TB) and supports CMD-style partitions, subdirectories, timestamps and filenames up to 255 characters. It is the DOS built into the Commander X16.
This is the base features set compared to other Commodore DOS devices:
Feature | 1541 | 1571/1581 | CMD HD/FD | SD2IEC | CMDR-DOS |
---|---|---|---|---|---|
Sequential files | yes | yes | yes | yes | yes |
Relative files | yes | yes | yes | yes | not yet |
Block access | yes | yes | yes | yes | not yet |
Code execution | yes | yes | yes | no | yes |
Burst commands | no | yes | yes | no | no |
Timestamps | no | no | yes | yes | yes |
Time API | no | no | yes | yes | not yet |
Partitions | no | no | yes | yes | yes |
Subdirectories | no | no | yes | yes | yes |
It consists of the following components:
- Commodore DOS interface
main.s
: TALK/LISTEN dispatchingparser.s
: filename/path parsingcmdch.s
: command channel parsing, status messagesfile.s
: file read/write
- FAT32 interface
match.s
: FAT32 character set conversion, wildcard matchingdir.s
: FAT32 directory listingfunction.s
: command implementations for FAT32
- FAT32 implementation
fat32/*
: FAT32 for 65c02 library
CMDR-DOS implements the TALK/LISTEN layer (Commodore Peripheral Bus layer 3), it can therefore be directly hooked up to the Commodore IEEE KERNAL API (talk
, tksa
, untlk
, listn
, secnd
, unlsn
, acptr
, ciout
) and be used as a computer-based DOS, like on the C65 and the X16.
CMDR-DOS does not contain a layer 2 implementation, i.e. IEEE-488 (PET) or Commodore Serial (C64, C128, ...). By adding a Commodore Serial (aka "IEC") implementation, CMDR-DOS could be adapted for use as the system software of a standalone 65c02-based Serial device for Commodore computers, similar to an sd2iec device.
The Commodore DOS side and the FAT32 side are well separated, so a lot of code could be reused for a DOS that uses a different filesystem.
Or the core feature set, these are the supported functions:
Feature | Syntax | Supported | Comment |
---|---|---|---|
Reading | ,?,R |
yes | |
Writing | ,?,W |
yes | |
Appending | ,?,A |
not yet | |
Recovery | ,?,M |
no | not useful on FAT32 |
Types | ,S /,P /,U /,L |
yes | ignored on FAT32 |
Overwriting | @: |
yes | |
Magic channels 0/1 | yes | ||
Channel 15 command | command: args... |
yes | |
Channel 15 status | code, string, a, b |
yes | |
CMD partition syntax | 0: /1: /... |
yes | |
CMD subdirectory syntax | //DIR/: //DIR/: |
yes | |
Directory listing | $ |
yes | |
Dir with name filtering | $:FIL* |
yes | |
Dir with type filtering | $:*=P /$:*=D /$:*=A |
yes | |
Dir with timestamps | $=T |
yes | but with ISO syntax |
Dir with time filtering | $=T< /$=T< |
not yet | |
Partition listing | $=P |
yes | |
Partition filtering | $:NAME*=P |
no |
And this table shows which of the standard commands are supported:
Name | Syntax | Description | Supported |
---|---|---|---|
BLOCK-ALLOCATE | B-A medium medium track sector |
Allocate a block in the BAM | no1 |
BLOCK-EXECUTE | B-E channel medium track sector |
Load and execute a block | not yet |
BLOCK-FREE | B-F medium medium track sector |
Free a block in the BAM | no1 |
BLOCK-READ | B-R channel medium track sector |
Read block | no1 |
BLOCK-STATUS | B-S channel medium track sector |
Check if block is allocated | no1 |
BLOCK-WRITE | B-W channel medium track sector |
Write block | no1 |
BUFFER-POINTER | B-P channel index |
Set r/w pointer within buffer | not yet |
CHANGE DIRECTORY | CD [path]: name |
Change the current sub-directory | yes |
CHANGE DIRECTORY | CD [medium]:← |
Change sub-directory up | yes |
CHANGE PARTITION | CP num |
Make a partition the default | yes |
COPY | C [path_a]: target_name= [path_b]: source_name[, ...] |
Copy/concatenate files | yes |
COPY | C dst_medium= src_medium |
Copy all files between disk | no1 |
DUPLICATE | D: dst_medium= src_medium |
Duplicate disk | no1 |
FILE LOCK | F-L [path]: name[, ...] |
Enable file write-protect | yes |
FILE RESTORE | F-R [path]: name[, ...] |
Restore a deleted file | not yet |
FILE UNLOCK | F-U [path]: name[, ...] |
Disable file write-protect | yes |
GET DISKCHANGE | G-D |
Query disk change | yes |
GET PARTITION | G-P num |
Get information about partition | yes |
INITIALIZE | I [medium] |
Re-mount filesystem | yes |
LOCK | L [path]: name |
Toggle file write protect | yes |
MAKE DIRECTORY | MD [path]: name |
Create a sub-directory | yes |
MEMORY-EXECUTE | M-E addr_lo addr_hi |
Execute code | yes |
MEMORY-READ | M-R addr_lo addr_hi [count] |
Read RAM | yes |
MEMORY-WRITE | M-W addr_lo addr_hi count data |
Write RAM | yes |
NEW | N [medium]: name, id,FAT32 |
File system creation | yes3 |
PARTITION | / [medium][: name] |
Select 1581 partition | no |
PARTITION | / [medium]: name, track sector count_lo count_hi ,C |
Create 1581 partition | no |
POSITION | P channel record_lo record_hi offset |
Set record index in REL file | not yet |
REMOVE DIRECTORY | RD [path]: name |
Delete a sub-directory | yes |
RENAME | R [path]: new_name= old_name |
Rename file | yes |
RENAME-HEADER | R-H [medium]: new_name |
Rename a filesystem | yes |
RENAME-PARTITION | R-P: new_name= old_name |
Rename a partition | no1 |
SCRATCH | S [path]: pattern[, ...] |
Delete files | yes |
SWAP | S- {8 |9 |D } |
Change primary address | yes |
TIME READ ASCII | T-RA |
Read Time/Date (ASCII) | no4 |
TIME READ BCD | T-RB |
Read Time/Date (BCD) | no4 |
TIME READ DECIMAL | T-RD |
Read Time/Date (Decimal) | no4 |
TIME READ ISO | T-RI |
Read Time/Date (ISO) | no4 |
TIME WRITE ASCII | T-WA dow mo/ da/ yr hr: mi: se ampm |
Write Time/Date (ASCII) | no4 |
TIME WRITE BCD | T-WB b0 b1 b2 b3 b4 b5 b6 b7 b8 |
Write Time/Date (BCD) | no4 |
TIME WRITE DECIMAL | T-WD b0 b1 b2 b3 b4 b5 b6 b7 |
Write Time/Date (Decimal) | no4 |
TIME WRITE ISO | T-WI yyyy- mm- ddT hh: mm: ss dow |
Write Time/Date (ISO) | no4 |
U1/UA | U1 channel medium track sector |
Raw read of a block | not yet |
U2/UB | U2 channel medium track sector |
Raw write of a block | not yet |
U3-U8/UC-UH | U3 - U8 |
Execute in user buffer | not yet |
U9/UI | UI |
Soft RESET | yes |
U:/UJ | UJ |
Hard RESET | yes |
USER | U0> pa |
Set unit primary address | yes |
USER | U0>B flag |
Enable/disable Fast Serial | no |
USER | U0>D val |
Set directory sector interleave | no1 |
USER | U0>H number |
Select head 0/1 | no1 |
USER | U0>L flag |
Large REL file support on/off | no |
USER | U0>M flag |
Enable/disable 1541 emulation mode | no1 |
USER | U0>R num |
Set number fo retries | no1 |
USER | U0>S val |
Set sector interleave | no1 |
USER | U0>T |
Test ROM checksum | no5 |
USER | U0>V flag |
Enable/disable verify | no1 |
USER | U0> pa |
Set unit primary address | yes |
USER | UI {+ |- } |
Use C64/VIC-20 Serial protocol | no1 |
UTILITY LOADER | & [[path]: ]name |
Load and execute program | no1 |
VALIDATE | V [medium] |
Filesystem check | no2 |
WRITE PROTECT | W- {0 |1 } |
Set/unset device write protect | yes |
- 1: outdated API, not useful, or can't be supported on FAT32
- 2: is a no-op, returns
00, OK,00,00
- 3: third argument
FAT32
has to be passed - 4: CMDR-DOS was architected to run on the main computer, so it shouldn't be DOS that keeps track of the time
- 5: Instead of testing the ROM, this command currently verifies that no buffers are allocated, otherwise it halts. This is used by unit tests to detect leaks.
The following added commands and features are specific to CMDR-DOS:
Feature | Syntax | Description |
---|---|---|
Open for Read & Write | ,?,M |
Allows arbitrarily reading, writing and setting the position (P )1 |
POSITION | P channel p0 p1 p2 p3 |
Set position within file (like sd2iec); all args binary |
- 1: once the EOF has been reached while reading, no further reads or writes are possible.
All currently unsupported commands are decoded in cmdch.s
anyway, but hooked into 31,SYNTAX ERROR,00,00
, so adding features should be as easy as adding the implementation.
Copyright 2020 Michael Steil <[email protected]>
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
-
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
-
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.