CM-COCOS revision 3

What is CM-COCOS?

It's "COMMODORE MEDIA - COMMON COMMAND SET". The goal of this document is to provide common commands and common media access methods for storage device developers/software authors, independent of hardware/filesystem design. (of course filesystems must have all features, except otherwise noted)

Notations used in this document:

Everything between "[" and "]" is optional.
Everything between "<" and ">" is user supplyed string/number.
"A" is CHR$(65), not CHR$(193)!

This document is written in HTML 4.01 Transitional with CSS1. Use browser version 5 or above in 1024x768, or text based browser with table rendering.
Most recent version available at http://singularcrew.hu/cm-cocos/.
CM-COCOS mailinglist: cm-cocos-request at c64.rulez.org

Introduction to disk management:

Partitions:

Disks are divided into partitions. Partitions are separate namespaces identified by a number between 1-254. Partition #0 is special, it's an alias of the active partition. Partition #255 is reserved. After power on the default partition number (which is stored on disk) is used to select the active partition. Number of useable partitions is filesystem specific.

Partitions can be listed by opening/loading "$=P". Using channel numbers of 2-14 gives raw data, and is therefore filesystem specific. Channel #1 is invalid. Channel #0 is same as load.

Expected return from drive after loading/opening channel #0 for partition listing:

First basic line looks like following (this includes $0401 starting address at the beginning!):

OFFSET01234567
$0000$01$04$01$01$00$00$12$22
$0008Global disklabel padded with $20 at it's end, if shorter
$0010
$0018$22$20Disk ID$00

Normal lines look like following (padding is done so that BASIC listing should look like as in example!):

OFFSET01234567
$0000$01$01PnumberSome $20 padding
$0008Partition name between $22, and $20 padding
$0010
$0018Partition type and $20 padding$00

Last basic line holds partition count ("X PARTITIONS."):

OFFSET01234567
$0000$01$01Count$50$41$52$54
$0008$49$54$49$4F$4E$53$2E$20
$0010$20$20$20$20$20$20$20$20
$0018$20$20$20$20$20$00$00$00

Example partition listing in BASIC:

LOAD"$=P",12
SEARCHING FOR $=P
LOADING
READY.
LIST
                                        
255 "GLOBAL DISKLABEL" IDE64
1    "ROOT PARTITION"  *NAT
2    "MY STUFFZ"        NAT
222  "BACKUP"           NAT<
3 PARTITIONS.
READY.

The BASIC linenumber before partition's name is it's number.
* indicates the default partition.
NAT indicates partition's type, it's meaning is filesystem specific.
< indicates that a partition is readonly.
Hidden partitions are not listed.

The global disklabel, the default partition, the partitions names, and it's attributes may be changed from the format utility. Changing active partition, getting active partition's number is done via channel #15 commands. If [<partition>] is not specified in commands, then the active partition's number is used as default.

Directorys:

Files can be organized into a tree of directorys. The number of files in one directory is only limited by the capacity of the partition. However it's not recommended to store more than 200 files in a directory due to performance reasons. The depth of directory tree is not limited, but it's not recommended create more than 200 character long pathnames. (The command channel is limited to 255 bytes, and some programs might not like it.)

The top level directory is called the root directory. All directorys have their own label, it's usually the same as the "DIR" file's name holding them, and the root directory has the partition's name as default.

Subdirectorys are indicated in file listing with file type "DIR". Creating, changing, renaming, moving, deleting, changing label are done via channel #15 commands.

[<path>] is a pathname, it's structure: [[/][/dir1][/dir2][....]/] If first / is present it's an absolute path ("//home/") otherwise it's relative from the current directory ("/dir/"). If [<path>] missing it's the current dir. (this type of pathname is the CMD style pathname. Example for load: "13//home/soci/:file") If path elements contain wild characters, they match the first occurance when searching.

Another way is to include path into filename directly. (this type is the un*x style pathname. [<path>] is omitted, only the filename contains the path. Example for load: "13:/home/soci/file") Filenames containing "/" have path in front of them. Examples (left un*x, right CMD):

"/tmp/d" is same as "//tmp/:d"
"home/soci/fd" is same as "/home/soci/:fd"
"home/soci/" is same as "/home/soci/:"
"//home/:soci/cs" is same as "//home/soci/:cs" or "/home/soci/cs".
Do not use both UNIX and CMD path!

There are some special directorys, which are virtually always present:
"." is the current directory.
".." is the parent directory.
This means that there can't be files called "." and "..".

Listing directorys:

Listing of directorys are done by opening/loading "$". Using channel numbers of 2-14 will give raw data of the directory instead, which is filesystem specific. Channel #1 is invalid. Channel #0 is same as load.

"$[[=<special>][=<units>][<partition>][<path>]:][<filename>][=<filetype>]"

Expected return from drive after loading/opening channel #0 for directory listing:

OFFSET01234567
$0000$01$04$01$01$00$00$12$22
$0008Directory label padded with $20 at it's end, if shorter
$0010
$0018$22$20Disk ID$00

Normal lines look like following (padding is done so that BASIC listing should look like as in example!):

OFFSET01234567
$0000$01$01PnumberSome $20 padding
$0008Filename between $22, and $20 padding
$0010
$0018Filetype and $20 padding$00

Last basic line holds total block count ("X BLOCKS USED.", if overflowd, it's 65535):

OFFSET01234567
$0000$01$01Count$42$4C$4F$43
$0008$4B$53$20$55$53$45$44$2E
$0010$20$20$20$20$20$20$20$20
$0018$20$20$20$20$20$00$00$00

Example directory listing:

LIST
                                        
1 "DIRLABEL        " ZIP64
23   "TASM"             PRG<
0    "DATA"             DIR
0    "MSX"             *SID
23 BLOCKS USED.
READY.

The number before the directory label indicates always the partition's number.
* indicates file wasn't closed (splat file). Use "V[ALIDATE]" or scandisk utility! Data may be recovered useing "M[ODIFY]".
< indicates file is not writeable or not deleteable.
Hidden files are not listed.

If [<filename>] or [=<filetype>] is missing it defaults to any file/any type.

<special> can be the following:

"P" Partition listing, see partitions above.
"T" Display additional time information.
"D" Normal directory listing, with absolute path instead of directory label.
"A" All data, drive independent format.

<units> defines "block length". Default is 256 bytes. Overflow is indicated by 65535.

"B" 1 byte
"K" 1024 bytes (1Kb)
"M" 1048576 bytes (1Mb)

Additional time information looks like (note that only the first char is displayed for filetype, and all user filetypes are "P"):

LIST
                                        
1 "DIRLABEL        " ZIP64
23   "TASM"             P 12/31 05.59 A
0    "DATA"             D 04/21 03.42 P
0    "MSX"             *P 02/14 02.29 A
23 BLOCKS USED.
READY.

Getting current workdir with "$=D":

LIST
                                        
1 "/HOME/SOCI" ZIP64
23   "TASM"             PRG<
0    "DATA"             DIR
0    "MSX"             *SID
23 BLOCKS USED.
READY.

All data mode consists of 2 bytes of load address ($00, $08) as the first 2 bytes, than 32 bytes data for each filename:

OFFSET01234567
$0000Filename padded with $00 at it's end if shorter then 16 characters
$0008
$0010YearMonthDayHourMinSecFlags
$0018TypeFiletype padded by $00Filesize

Time is in BCD. Year: $80-$99 => 1980-1999, $00-$79 => 2000-2079
Flags: CDRWXH?? ????????
Type: $00=DEL, $01=SEQ, $02=PRG, $03=USR, $04=REL, $05=CBM, $06=DIR, $07=LNK, $08...
Filetype is present also for "USR", etc. 4 characters of filesize is in binary.
The directory label is always included as first file, filetype is "DIR", type is 6, filesize is 0, flags are same as it's "DIR" entry.

Using of wildcards (with directory listing):

There are 2 kind of wildcards: "?" and "*". "?" matches exactly 1 character, while "*" matches any number of characters (including null).

Here's some examples of directory filtering drives should accept:

LOAD"$F*",12 List files beginning with "F"
LOAD"$M?S",12 List files where "?" is a not specified character.
LOAD"$ROB*=SID",12 List files with type "SID" beginning with "ROB".
LOAD"$3:*=A*",12 List files from 3rd partition's current dir with filetype beginning with "A".
LOAD"$=T=K5/DAT*/:C*" List files from the first dir beginning with "DAT" where filenames beginning with "C", plus additional time information. File sizes in Kb.
LOAD"$*.O" List files ending with ".O"
LOAD"$A*IZ*EQ" List files beginning with "A", containing "IZ" and ending with "EQ".
LOAD"$A*B*C*" List files beginning with "A", then containing a "B", and then a "C".

Permission policies for directorys:

Only deleteable empty directorys can be removed.
Only readable directory can be listed.
Only in writeable directory can files be deleted/renamed/created/moved.
Only executeable directory can be in path, otherwise directory is skipped.

Files:

Data is stored in different type of files. Predefined [<filetype>]s are:

"DEL", "D" Mostly used as directory separator, it can't hold data.
"SEQ", "S" Used for sequential files.
"PRG", "P" Program files.
"USR", "U" Used for compatibility.
"REL", "R", "L" Relative files.
"CBM", "C" Reserved for future use.
"DIR", "B" Subdirectory.
"LNK", "J" Link file.

Everything else can be user defined, but still open/loadable with type "P". If not specified, default is "P". Note that if there are files with same names the first will be opened if "P" is used.

Invalid characters in filename/type are: CHR$(0), ":", "=", ",", "*", "?", "/".
It's not recommended to create filename beginning with "$", "#", or containing CHR$(13), CHR$(34), CHR$(96)-CHR$(159), CHR$(224)-CHR$(254), otherwise using such files will be tricky. Also filetype containing uppercase letters (CHR$(128) and above) will result in interesting directory listing in basic.

Opening a file can be done with different [<filemode>]s:

"R[EAD]" open file for reading (file must exist)
"W[RITE]" open file for exclusive writing+reading (will be created, if exists replace must be used.)
"A[PPEND]" open file for exclusive writing+reading and position to the end of file (file must exist). No seeking this time!
"M[ODIFY]" open file for exclusive read and write (file data is preserved, if not exist it's created. Replaceing is ignored).
if file is not closed (splat file) then open it for sequential reading to recover data.

Seeking is allways possible except otherwise noted.

For more see filetypes below.

Permission policies:

Only readable files can be opened for read.
Only writeable files can be opened for write/append.
Only readable and writeable files can be opened for modify.
Only executeable files can be loaded, otherwise file is skipped.

Channel #0 implies load mode. Channel #1 implies save mode. (write) Using files with this channel numbers ignores the filemode specified!

Using "@[<partition>]:<filename>" will replace old file with same name if used when opening files for write/save. (only deleteable+writeable files will be replaced!) Don't forget to use partition number 0 for current partition to avoid a bug when used with CBM DOS!

Same filenames with different type are allowed, but correct filetype must be specified if used!

Normal files size are limited to 4Gb or by size of partition. Relative files are limited to 16Mb, because: 255 byte long record*65535. If more than 255 byte record length and/or bigger then 16Mb data is required and/or CHR$(0) is required, it's better to use normal files with manual seeking.

DEL files:

Del files cannot hold data, they are just used as directory separator.

Creating a DEL file:

OPEN <lfn>,<device>,<channel>,"[[<partition>][<path>]:]<filename>,DEL[,WRITE]"
CLOSE <lfn>

Only [,WRITE] is allowed, but may missing.
Default flags: -D---, are not changeable!

Normal files:

Normal files are "SEQ", "PRG", "USR", and all user defined ones.

Creating a normal file:

OPEN <lfn>,<device>,<channel>,"[[@][<partition>][<path>]:]<filename>,<type>,WRITE"

",WRITE" is not required if channel #1 is used.
Default flags: -DRW-

Opening an existing file for read:

OPEN <lfn>,<device>,<channel>,"[[<partition>][<path>]:]<filename>[,<type>[,READ]]"

If [,<type>] is ",P" it matches the first "PRG" or user type file.
If [,<type>] is ",PRG" it matches the first "PRG" type file.
If [,<type>] is ",<type>" it matches the first "<type>" type file.

Wildcards in filename matches first occurance.

Opening an existing file for append:

OPEN <lfn>,<device>,<channel>,"[[<partition>][<path>]:]<filename>,<type>,APPEND"

For [,<type>] see above.

Opening an existing file for read and write:

OPEN <lfn>,<device>,<channel>,"[[<partition>][<path>]:]<filename>,<type>,MODIFY"

For [,<type>] see above.

Saving an executeable file:

SAVE"[[@][<partition>][<path>]:]<filename>[,<type>]"[,<device>]

Default flags: -DRWX

Loading an existing executeable file:

LOAD"[[<partition>][<path>]:]<filename>[,<type>]"[,<device>[,<mode>]]

For [,<type>] see above.
If [,<type>] is not specified the first executeable "PRG" is loaded, otherwise non executeables can be loaded too.
<mode> is used by BASIC to identity which load address have to be used. (0=default, other=from file)

Seeking in read and modify mode is done by channel #15 commands.

REL files:

Relative files are used only for compatibility. Historically this filetype was the only one with random access. Relative files consist of records with the same <length> from 1 to 255. There can be upto 65535 records, so the total maximum filesize is 16711425 bytes.

Creating a relative file with record length of <length>:

OPEN <lfn>,<device>,<channel>,"[[<partition>][<path>]:]<filename>,L,"+CHR$(<length>)

Default flags: -DRW-

Opening an existing relative file:

OPEN <lfn>,<device>,<channel>,"[[<partition>][<path>]:]<filename>[,L]"

No need for mode specification!

Positioning in file is done via channel #15 commands.
Records containing CHR$(0) will be truncated there.
Reading last byte of record sets ST to $40.

CBM files:

CBM files were historically used as partitions. Now reserved for future use.

DIR files:

See directory section for more!

Only the "$" method is available for accessing them.

Opening regular directory listing:

OPEN <lfn>,<device>,0,"$[=<special>][=<units>][[<partition>][<path>]:][<filename>][=<filetype>]"

Opening raw directory listing:

OPEN <lfn>,<device>,<2-14>,"$[=<special>][[<partition>][<path>]:][<filename>][=<filetype>]"

Loading regular directory listing:

LOAD"$[=<special>][=<units>][[<partition>][<path>]:][<filename>][=<filetype>]"[,<device>[,<mode>]]

Getting a list of a "DIR" file (<dirname>) in current dir (trivial from above):

"$[=<special>][=<units>][[<partition>]/<dirname>/:[<filename>][=<filetype>]" or "$[=<special>][=<units>][[<partition>]:<dirname>/[<filename>][=<filetype>]"

Default flags: -DRWX

LNK files:

Link files are just small files containing a relative/absolute path.

Loading/opening this file will cause the open/load of the file it points to. Deleting a link will not affect the original file.

Creating a link:

OPEN <lfn>,<device>,<channel>,"[[@][<partition>][<path>]:]<filename>,LNK,WRITE"
PRINT#<lfn>,"[<path>:]<filename>":CLOSE <lfn>

Default flags: -DRWX

Reading where the link points to:

OPEN <lfn>,<device>,<channel>,"[[<partition>][<path>]:]<filename>,LNK[,READ]"

[,APPEND] and [,MODIFY] are not valid modes, [,READ] is default if missing.

While including a link into path an error may happen if path buffer overflows.

Everywhere LOAD can be used VERIFY is also available. (Yes, for directorys to, but does not make much sense...)

Channel #15 commands:

Channel #15 is used for disk commands and error reporting as usual. There's a a 256 byte buffer for commands, so the maximal length of disk command is limited to 255 bytes. Closing of channel #15 will cause open files to be closed. Reading last byte of returned data (error message) sets ST to $40.

Normal commands:

Changing partition:

"CP<partition>"
or
"C"+CHR$(208)+CHR$(<partition>) (CHR$(208) is shift+P)

Getting current partition:

"G-P"
After this the following bytes are returned:
OFFSET01234567
$0000TypeInfoCurrent$0D 

Type: $01=native, $02=1541, $03=1571, $04=1581, $05=1581 CP/M, $06=Spool, $07=REU, $08..

Info:
Bit 7: Disc in drive (1=yes)
Bit 6: Disc formatted (1=yes)
Bit 5: CMD-formatted (1=yes)
Bit 4: real 1581-disc (1=yes)
Bit 3-0 format of disc
0000: unknown
0001:800K
0010:1,6MB
0100:3,2MB
0101:720K
0110:1,44MB
0111:2,88MB
1000-1111: ?
Current: active partition (1-254)

Deleting files:

"S[CRATCH][<partition>][<path>]:<filename1>[=<type>][,[[<partition>][<path>]:]<filename2>[=<type>][,...]]"
Delete one or more files/empty directorys. Wildcards "?" and "*" are supported in both filenames and filetypes. Only deleteable files can be deleted. Missing [=<type>] means any filetype!

Renaming file or directory:

"R[ENAME][<partition>][<path>]:<newname>[,<newtype>]=[[<partition>][<path>]:]<oldname>[,<oldtype>]"
Rename/move file and/or change filetype or rename directory.
Wildcards in filenames or filetypes is not supported. If oldfiletype is not specified, the first occurance of filename will be renamed/used. If newfiletype is not specified, the oldtype is the default, or the type of oldfile.

Copying file or merging files

"C[OPY][<partition>][<path>]:<newname>[,<newtype>]=[[<partition>][<path>]:]<file1>[=<type>][,[[<partition>][<path>]:]<file2>[=<type>][,...]]"
Copy/concat files.
Wildcards in filenames or filetypes are not supported. If filetype is not specified, the first occurance of filename will be used. If newfiletype is not specified, it's "PRG".
Default flags for created file: -DRW-

Initialize drive:

"I[NITIALIZE][<partition>]"
If partition not specified then close all files and go to root dir of default partition, else close all files on partition and go to root dir.

Check filesystem:

"V[ALIDATE][<partition>]"
If partition not specified then it is the active partition. For complex filesystems requering external program for consistency check may ignore this command with "00, OK,000,000,000,000".

Create filesystem:

"N[EW][<partition>]:<rootdirlabel>[,<id>]"
Should be ignored with "26, WRITE PROTECT ON,000,000,000,000".
Use format utility.

Duplicate filesystem:

"D[UPLICATE]<partitionto>=<partitionfrom>"
Should be ignored with "31, UNKNOWN COMMAND,000,000,000,000"

Set new directory label:

"R-H[<partition>][<path>]:<newname>"
The directory label is changed.

Create new directory:

"M[D][<partition>][<path>]:<newdir>"
New directory is created.

Change directory:

"C[D][<partition>][<path>]:<dirname>"
The current directory is changed to new one.
"CD[[<partition>]:]"+CHR$(95)
Go to parent dir. (CHR$(95) is the left arrow. Can't be included into path as parent dir!)
Wether "C:" is used as dirchange or copy it's easily recogniseable by searching for "=".

"/[[<partition>[<path>]]:][<dirname>]"
If [<dirname>] is missing, than root directory is selected.

Delete empty directory:

"R[D][<partition>][<path>]:<dirname>"
Directory is deleted if it was empty. Only deleteable dir can be deleted.

Change file position:

"P"+CHR$(<secondary address>)+CHR$(<low>)+CHR$(<high>)+CHR$(<record position>)
Used for relative files. Values 1 to 65535 are valid. 0 is same as 1. Values for <record position> are from 1 to 255. 0 is same as 1.
Positioning beyond last record, and than writing will cause skipped records filled with one CHR$(255) character. "P"+CHR$(<secondary address>)+CHR$(<lowest>)+CHR$(<low>)+CHR$(<high>)+CHR$(<highest>)
Used for all regular files. Values of 0 to 4294967295 are valid.
Positioning beyond end of file, and than writing will cause skipped records filled with CHR$(0) characters.

Attaching an image file as partition:

"A[<partition>][<path>]:<filename>=<partition>"
Will be used by CMD HD. (detaching, etc. not cleared yet, maybe this will copy the file into an emulation partition???)

Executing utility:

"&[<partition>][<path>]:<filename>"
Utility loader. Drive specific, implementation not required.

Getting/changing files flags:

"L[<partition>][<path>]:<filename>[=<type>][,<action>[<flags>]]"
<flags> is a string of "HDRWX" characters:
"H" Hidden
"D" Deleteable
"R" Readable
"W" Writeable
"X" Executeable
<action> is a character of "-+=?".
"-" Clear this flags
"+" Set this flags
"=" Use this flags
"!" Invert this flags
"?" Reported current state followed by a CHR$(13). No wildcards in this case!
If [<action><flags>] is missing, then writeable flag will be inverted and deleteable will have the same state as writeable.
Wildcards in filename and type are allowed for multiple files changes.
The executeable flag is only valid for "PRG" and "DIR". Otherwise it's always 0.

Getting time:

"T-RA"
Return time as ascii string:
OFFSET01234567
$0000Day of week$20Month$2F
$0008Day$2FYear$20Hour
$0010$3AMin$3ASec$20A/P
$0018$4D$0D 

Day of week: 4 character string of day names: "SUN.", "MON.", "TUES", "WED.", "THUR", "FRI.", "SAT.".
Year: "80"-"99" => 1980-1999, "00"-"79" => 2000-2079
Month: "01"-"12"
Day: "01"-"31"
Hour: "01"-"12"
Minute: "00"-"59"
Second: "00"-"59"
A/P: "A" for AM, "P" for PM.

"T-RB"
Time in 8 byte binary format:
OFFSET01234567
$0000DOWYearMonthDayHourMinSecAM/PM
$0008$0D 

DOW (Day of week): 0-7, 0=Sunday, 1=Monday... 6=Saturday
Year: 80-99 => 1980-1999, 0-79 => 2000-2079
Month: 1-12
Day: 1-31
Hour: 1-12
Minute: 0-59
Second: 0-59
AM/PM: 0=AM, non-zero=PM

"T-RD"
Same as "T-RB", but in BCD.

Setting time:

"T-WAMON. 09/10/01 11:33:00 AM"
Time is ascii format. September 10, 2001 11:33 AM. See reading above.
"T-WB"+CHR$(<dayofweek>)+CHR$(<year>)+CHR$(<month>)+CHR$(<day>)+CHR$(<hour>)+CHR$(<minute>)+CHR$(<second>)+CHR$(<ampm>)
Time in binary format.
"T-WD"+CHR$(<dayofweek>)+CHR$(<year>)+CHR$(<month>)+CHR$(<day>)+CHR$(<hour>)+CHR$(<minute>)+CHR$(<second>)+CHR$(<ampm>)
Numbers must be in BCD format!

User commands:

"U0>"+CHR$(<device number>)
Change device number. (device number must be 4<=X<=30, 0 means off, powermanagement may powerdown drive)
"U0>E"+CHR$(<mode>)
Eject (1 or 49) or load (0 or 48) media.
"U0>L"+CHR$(<mode>)
Lock (1 or 49) or unlock (0 or 48) media.
"U0>P"+CHR$(<mode>)
Leave (1 or 49) or enter (0 or 48) power saving mode.
"U0>R"+CHR$(<retry>)
Set error retry count.
"U0>T"
Start diagnostics.
"U1 <channel> <partititon> <track> <sector>"
Same as block-read, but position is 0. Provided for compatibility. Drive specific, implementation not required.
"U2 <channel> <partititon> <track> <sector>"
Same as block-write. Provided for compatibility. Drive specific, implementation not required.
"U3"-"U8" and "UA"-"UH"
Reserved.
"UI" or "U9"
Get dos version. ("73, ...")
"UJ" or "U:"
Initialize all device(s) to power on state.

Memory commands:

"M-R"+CHR$(<low>)+CHR$(<high>)+CHR$(<count>)
Read bytes from drive's memory. Drive specific, implementation not required.
"M-W"+CHR$(<low>)+CHR$(<high>)+CHR$(<count>)+CHR$(<data>)+..
Write bytes to drive's memory. Drive specific, implementation not required.
"M-E"+CHR$(<low>)+CHR$(<high>)
Execute program in drive's memory. Drive specific, implementation not required.

Block commands:

These are direct access commands. First a direct channel have to be opened:
OPEN <lfn>,<device>,<channel>,"#[<buffer>]"
Channel numbers of 2-14 are valid, channels #0 and #1 are invalid.
With [<buffer>] it's possible to force which buffer (0-9) to be used, but it can already be in use. Commands are applied to channel #15, while data is transfered through <channel>.
Buffer length is drive specific. (ST sets to $40 if last byte of buffer reached) Buffer is circular.

"B=R"+CHR$(<channel>)+CHR$(<address1>)+CHR$(<address2>)+CHR$(<address3>)+CHR$(<address4>)
Read a block into buffer identified by channel number. Drive specific, implementation not required.
"B=P"+CHR$(<channel>)+CHR$(<low>)+CHR$(<high>)
Set position in buffer identified by channel number. Drive specific, implementation not required.
"B=W"+CHR$(<channel>)+CHR$(<address1>)+CHR$(<address2>)+CHR$(<address3>)+CHR$(<address4>)
Write a block out from buffer identified by channel number. Drive specific, implementation not required.
"B=E"+CHR$(<channel>)+CHR$(<address1>)+CHR$(<address2>)+CHR$(<address3>)+CHR$(<address4>)
Read a block into buffer identified by channel number, and than execute. Drive specific, implementation not required.
"B[LOCK]-R[EAD][:] <channel> <partititon> <track> <sector>"
Read a block into buffer identified by channel number. Position is set to 2. Provided for compatibility. Drive specific, implementation not required.
"B[LOCK]-W[RITE][:] <channel> <partititon> <track> <sector>"
Write a block out from buffer identified by channel number. Povided for compatibility. Drive specific, implementation not required.
"B[LOCK]-E[XECUTE][:] <channel> <partititon> <track> <sector>"
Read a block into buffer identified by channel number, and than execute. Provided for compatibility. Drive specific, implementation not required.
"B[LOCK]-P[OSITION][:] <channel> <position>"
Set position (0-255) in buffer identified by channel number. Provided for compatibility. Drive specific, implementation not required.
"B[LOCK]-A[LLOCATE][:] <partititon> <track> <sector>"
Mark a block as used. Provided for compatibility. Drive specific, implementation not required.
"B[LOCK]-F[REE][:] <partititon> <track> <sector>"
Mark a block as free. Provided for compatibility. Drive specific, implementation not required.

CM-COCOS error messages:

Error messages consist of 6 parts separated by colon:
1st: Error code (00-99)
2nd: Error description as text
3rd-6th: Additional informations (000-255)

00, OK,000,000,000,000

No errors since last action.

01, FILES SCRATCHED,XXX,YYY,000,000

XXX+YYY*256 files where deleted.

02, PARTITION SELECTED,XXX,000,000,000

Partition number #XXX was selected.

20, READ ERROR,DP1,DP2,DP3,DP4

Unrecoverable read error. Maybe a defective disk.
DP1,DP2,DP3,DP4 is drive specific address of sector.

21, READ ERROR,DP1,DP2,DP3,DP4

Timeout during read.

22, READ ERROR,DP1,DP2,DP3,DP4

Data block not found, or unformatted media.

23, READ ERROR,DP1,DP2,DP3,DP4

Problem with data checksumm.

25, WRITE ERROR,DP1,DP2,DP3,DP4

Verify error.

26, WRITE PROTECT ON,000,000,000,000

Write protected file/dir/partition/media.

28, WRITE ERROR,DP1,DP2,DP3,DP4

Timeout during write.

29, DISK CHANGED,000,000,000,000

Disk change detected.

30, SYNTAX ERROR,000,000,000,000

Syntax error in command. (something is missing...)

31, UNKNOWN COMMAND,000,000,000,000

Unknown/unimplemented command.

32, SYNTAX ERROR,000,000,000,000

Command buffer overflow.

33, SYNTAX ERROR,000,000,000,000

Illegal character in filename.

34, SYNTAX ERROR,000,000,000,000

Missing filename.

39, PATH NOT FOUND,000,000,000,000

Path not found.

50, SEEK BEYOND END,000,000,000,000

Attempt to seek beyond end of file.

51, OVERFLOW IN RECORD,000,000,000,000

Record too long, truncated.

52, FILE TOO LARGE,000,000,000,000

Filesize reached 4Gb/16Mb.

60, WRITE FILE OPEN,000,000,000,000

Cannot read not propertly closed files.

61, FILE NOT OPEN,000,000,000,000

Cannot read/write to file, because it couldn't be opened.

62, FILE NOT FOUND,000,000,000,000

File not found in directory.

63, FILE EXISTS,000,000,000,000

File already exists in dir.

64, FILE TYPE MISMATCH,000,000,000,000

Filetype different than expected.

65, NO BLOCK,DP1,DP2,DP3,DP4

This returns next free block if block allocate failed. Provided for compatibility. Drive specific, implementation not required.

66, ILLEGAL REQUEST,DP1,DP2,DP3,DP4

Sector's address out of range in block commands.

67, ILLEGAL REQUEST,DP1,DP2,DP3,DP4

Sector's address out of range. (corrupted diskformat while reading not closed file)

70, NO CHANNEL,000,000,000,000

Out of buffers.

71, DIR ERROR,DP1,DP2,DP3,DP4

No directory header found.

72, PARTITION FULL,000,000,000,000

Partition is full.

73, IDE DOS Vx.xx IDE64,DP1,DP2,DP3,DP4
73, IDE DOS Vx.xx CDROM,DP1,DP2,DP3,DP4
73, IDE DOS Vx.xx ZIP64,DP1,DP2,DP3,DP4

Dos version, and drive type. Text is drive specific, examples for IDE64
DP1,DP2,DP3,DP4 contains the last accessable sector of drive in drive specific format.

74, DRIVE NOT READY,000,000,000,000

No disk in drive.

75, FORMAT ERROR,000,000,000,000

Disk not in known format. Use format command/utility.

76, CONTROLLER ERROR,XXX,000,000,000

Expect trouble...
001 - Battery low (non-fatal, recharge battery!)
002 - Rom checksumm error (IDE64: try reflashing, or 29C512 may be bad)
003 - Ram error (IDE64: 62256 may be bad)
004 - Controller error (IDE64: PLCC 1032E may be bad)
005 - Clock chip error (IDE64: DS 1302 may be bad)
006 - Quartz error (IDE64: Quartz for clock may be bad)
007 - Cable error (IDE64: Check IDE cable)
Others not yet specified.

77, SELECTED PARTITION ILLEGAL,XXX,000,000,000

Partition number #XXX not found/illegal. (0 if no match for name)

Unused error codes:

22, READ ERROR,000,000,000,000
24, READ ERROR,000,000,000,000
27, READ ERROR,000,000,000,000

-Soci/Singular-

Document maintained by:

Kajtár Zsolt
Szigliget
Hóvirág u.15.
8264
Hungary
mail: soci at c64.rulez.org