Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Commodore DOS
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===1541 directory and file types=== The 1541 Commodore floppy disk can contain up to 144 files in a flat namespace (no [[directory (computing)|subdirectories]]); the directory is stored on reserved track 18, which is located halfway from the hub to the edge of a 35-track single-sided disk. A file name may be up to 16 [[bytes]] in length and is theoretically unique; by using direct access methods on the directory structure, it is possible to rename a file to that of another—although accessing such files may be difficult or impossible. Files with identical names usually serve no purpose except to inform or visually manage files. One popular trick, used, for example, by [[The Final Cartridge III]], was to add files named <code>"----------------"</code> of type <code>DEL<</code> to the directory, and files could then be rearranged around those lines to form groups. Many game developers, [[warez]] group members, and [[demoscene]] hackers used some more clever custom directory entries as well. File names may contain a shifted space character (<code>[[Hexadecimal|$]]A0</code>), and if the directory listing is being viewed from BASIC, the portion of the file name beyond the <code>$A0</code> character will appear to have been separated from the first part of the file name by a quotation mark, causing [[Commodore BASIC|BASIC]] to not consider it to be part of the full file name. This feature can be used to create directory entries such as {{kbd|SAVE "PROGRAM{{keypress|shift|space|chain=–}} {{keypress|Commodore|D|chain=–}}{{keypress|U}}{{keypress|D}}{{keypress|E}}",8,1}}, which will then appear in the directory listing as, for example, {{samp|32 "PROGRAM",8,1 PRG}}.<ref>{{cite magazine|magazine=Commodore Power/Play|volume=4|issue=1|date=February–March 1985|title=Quick Load|page=[https://archive.org/details/commodore-power-play-13/page/n55 54]|last=Sturdivant|first=Jerry A.|url=https://archive.org/details/commodore-power-play-13|accessdate=2018-10-07}}</ref> When the user moves the cursor to the beginning of the line, types the word <code>LOAD</code> over the file size, and presses {{keypress|RETURN}}, BASIC interprets that as {{code|lang=cbmbas|LOAD "PROGRAM",8,1 ...}}, causing the program to be loaded into memory. Anything after the colon or the secondary address will not be executed, since the computer ignores any command after a LOAD.<ref>{{cite magazine|magazine=COMPUTE!'s Gazette|issue=6|date=December 1983|page=[https://archive.org/details/1983-12-computegazette/page/n214 178]|title=Horizons: 64|last=Brannon|first=Charles|url=https://archive.org/details/1983-12-computegazette|accessdate=2018-10-07}}</ref> Alternatively, the user could press {{keypress|shift|RUN/STOP|chain=–}} to {{code|lang=cbmbas|LOAD}} and {{code|lang=cbmbas|RUN}} the program automatically.<ref>{{cite magazine|title=A bizarre dude|last=Grace|first=Paul|magazine=RUN Special Issue 1987|date=1986|publisher=CW Communications/Peterborough, Inc.|location=Peterborough, New Hampshire|url=https://archive.org/details/run-magazine-1987-special/page/n37|accessdate=2018-10-07}}</ref> A null byte embedded in a file name will interrupt the listing after loading by BASIC. If there are three null bytes, that makes it difficult to list through BASIC. Many machine language programmers would experiment with null bytes in an attempt to make it harder for BASIC programmers to access their code and tamper with it. In BASIC, the directory can be accessed as a non-executable pseudo-BASIC program with {{code|lang=cbmbas|LOAD "$0",8}} (or {{code|lang=cbmbas|LOAD "$1",8}} in the case of a dual drive) followed by <code>LIST</code>. The first line has a line number of 0 or 1 (indicating the drive number), showing in reverse video the name and ID of the disk and a shorthand code for the DOS version with which it was created (codes vary only as far as the DOS versions use incompatible disk formats: "2A" is used by most 5.25-inch DOS versions, "3D" by the 3.5-inch 1581). Lines after this have the size of a file (in disk blocks) as their pseudo "line number", followed by the file name in quotes and the three-letter type code. The last line shows the number of unallocated blocks on the disk (again as a pseudo "line number"), followed by the words "BLOCKS FREE." On the [[Commodore 64]], entering {{code|lang=cbmbas|LOAD "$",8,1}} will flood the screen with garbage instead of loading the directory into BASIC RAM. This is because the drive assigns the directory a load address of [[Hexadecimal|$]]0401 (1025), which is equivalent to the start of BASIC for the [[Commodore PET]], but corresponds to the default screen memory in the C64 (starting with the second character on the first line of the screen). Viewing the directory with a {{code|lang=cbmbas|LOAD "$",8}} command overwrites the BASIC program in memory. The [[DOS Wedge]] and various third-party cartridges and extenders such as [[Epyx Fast Load]], [[Action Replay]], and [[The Final Cartridge III]] allow viewing of the disk directory using special commands that load the directory into screen memory without destroying the current BASIC program. Some versions of Commodore BASIC <!-- 3.5 and up? --> include a <code>DIRECTORY</code> or <!-- 4.0 and up? --><code>CATALOG</code> command that performs the same function. The following file types are supported: ;<code>SEQ</code> : A [[sequential access|sequential]] file is a data file that can be linearly read from start to finish. <code>SEQ</code> files are commonly used to store documents or text files created by a word processor or other such editor. A sequential file is analogous to a [[flat file]] in [[Linux]] or [[UNIX]], in that it has no specialized internal structure. It is not possible to position to any arbitrary location in a sequential file, as there is no analog of the <code>lseek</code> kernel call found in [[UNIX-like]] operating systems. ;<code>PRG</code> : <code>PRG</code> files normally contain executable program code, although they can also be used for data files. The first two bytes of the <code>PRG</code> are read by the [[KERNAL|kernal]] "load file" routine and used to determine the load address (they are stored in a [[endianness|little endian]] format). ;<code>REL</code> : A relative file is a variation of the sequential file type, in which an indexing mechanism referred to as side-sectors is present to permit record-oriented access. Records may be a maximum of 254 bytes in size and are addressed by a one-based cardinal number, permitting true [[random access]] to any part of the file. ;<code>USR</code> : A user-specified file has an internal structure that is identical to that of a sequential file. Commodore's original purpose for this file type was the facilitation of DOS development, as the file content could be copied into a drive buffer for execution by the drive's microprocessor. Very few programs ever made use of this file type. Some applications that use non-standard low-level disk structures save data in USR format, which came to be considered a sort of "leave me alone, don't try to copy or delete" indication to the user. Most notably, [[GEOS (8-bit operating system)|GEOS]]' "VLIR" files show up as <code>USR</code> files. ;<code>DEL</code> : An undocumented internally used file type similar in structure to a sequential file. Creation of this file type must be accomplished by direct manipulation of the disk directory. The presence of an asterisk (<code>*</code>) prepended to the file type in a directory listing (for example, <code>*SEQ</code>) indicates that the file was not properly closed after writing. When the drive is commanded to close a file that has been opened for writing, the associated buffer is flushed to the disk and the [[block availability map]] (BAM) is updated to accurately reflect which blocks have been used. If a program crash or other problem (such as the user removing the disk while a file is open) results in an "orphan file", also referred to as a "poison" or "splat" file, [[data buffer|buffers]] are not flushed and the BAM will not accurately reflect disk usage, putting the disk at risk of corruption. A poison file generally cannot be accessed (but can be opened in "modify" mode), and an attempt to use the DOS <code>scratch</code> command to delete the file may cause [[filesystem]] corruption, such as crosslinking. The only practical method of removing one of these files is by opening the file in "modify" mode (and fixing it), or by validating the disk (see the DOS <code>validate</code> command below), the latter which rebuilds the BAM and removes poison file references from the directory. The infamous [[#The_save-with-replace_bug|save-with-replace bug]] could result in creation of splat files. <code>*DEL</code> is a special type written into the on-disk directory entry of files that have been deleted. Such files are not shown in a normal directory listing, and their data blocks and directory entries will be reused by files that are subsequently created. Some utility programs allow the "un-deletion" of such files if their data blocks and directory entries haven not yet been overwritten by other files. <code>DEL files</code> are commonly used to insert banners or comment sections into a directory listing. File types with <code><</code> after them (for example, <code>PRG<</code>) are "locked", and cannot be deleted—they can be opened for reading, however. There is no Commodore DOS command that can explicitly set or clear this status, but many third-party utilities were written to allow this to be done. These utilities generally read the directory using direct-access commands, perform the necessary modifications to the raw data, and then write the changes back to the disk.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)