Home
Home
First Prev Contents Next Last
First - Prev - Contents - Next - Last
Deutsch
Deutsch

Appendix B: List of Floppy Disk Commands

Here is a short summary of the commands of hte 1541 Disk Drive. Note that this is not intended to be a tutorial, but just a quick reference to refresh long unused brain cells.
If you are looking for more complete reference with many examples, take a look at the original C1541 manual. It is available as etext at: http://project64.c64.org.

The 1541 Disk Drive is a flexible device in itself, containing a CPU, RAM and ROM it is a small computer that can execute many commands.

Use the following program to send the command to the floppy.

10 OPEN 1, 8, 15                  ; Open Command Channel
20 PRINT#1, Command$              ; Send Command
30 CLOSE 1                        ; Close Channel

With the following program you can display the current floppy status.

10 OPEN 1, 8, 15                  ; Open Error Channel
20 INPUT#1, EN$, ER$, TR$, SC$    ; Read Message
30 CLOSE 1                        ; Close Channel
40 PRINT "ErrNr: "; EN$           ; Display Results
50 PRINT "Error: "; ER$
60 PRINT "Track: "; TR$
70 PRINT "Sector:"; SC$

Power20 emulates the following commands for the emulated Commodore 1541 disk drives:

NEW - Format a floppy disk
Abbreviation: N
Syntax: "NEW:<diskname>,<id>"
Where <diskname> can be up to 16 characters long and <id> can either be omitted (only the directory is erased on a pre-formatted disk) or must be exactly 2 characters long.
COPY - Create a copy of a file on the same disk
Abbreviation: C
Syntax: "COPY:<destfile>=<sourcefile>" or
"COPY:<destfile>=<sourcefile1>, <sourcefile2>, ..."
If several source files are listed, than the destination file will contain the concatenated contents of all source files.
RENAME - Rename a file
Abbreviation: R
Syntax: "RENAME:<newname>=<oldname>"
SCRATCH - Delete files
Abbreviation: S
Syntax: "SCRATCH:<file>"
You can use the wild cards '?' and '*' to delete several files at once.
INITIALIZE - Reset the C1541 to power-up condition
Abbreviation: I
Syntax: "INITIALIZE"
VALIDATE - Check and Fix Disk Consistency
Abbreviation: V
Syntax: "VALIDATE"
Validate will fix inconsistencies that can be caused by files that where opened but never closed. Beware: Validate also erases all random files!
POSITION - Change the Read/Write Position in a Relative File
Abbreviation: P
Syntax: "P"+CHR$(Channel)+CHR$(RecLow)+CHR$(RecHi)+CHR$(Pos)
Example:
OPEN 15, 8, 15            ; Open Command Channel
OPEN  5, 8, 5, "RelativeFile,L,";CHR$(40)
                          ; Create Relative File with Recordsize
                          ; 40 Byte
PRINT#15,"P"+CHR$(5)+CHR$(17)+CHR$(0)+CHR$(1)
                          ; Set File Position to 1st Byte of
                          ; Record 17 (Numbering for Records and
                          ; BytePos starts with 1 (not 0))
PRINT#5,"Important Data"  ; Write Data
PRINT#15,"P"+CHR$(5)+CHR$(9)+CHR$(0)+CHR$(4)
                          ; Set File Position to 4th Byte of
                          ; Record 9 (Numbering for Records and
                          ; BytePos starts with 1 (not 0))
INPUT#5,X$                ; Read Data
CLOSE 5                   ; Close Channel
CLOSE 15                  ; Close Command Channel
BLOCK-READ - Read a Disk Block into the internal floppy RAM
Abbreviation: B-R
Syntax: "B-R:"+STR$(Channel)+STR$(Drive)+STR$(Track)+STR$(Sector)
Example:
OPEN 15, 8, 15            ; Open Command Channel
OPEN  5, 8, 5, "#"        ; Open Channel 5 to RAM buffer
PRINT#15,"B-R: 5 0 18 2"  ; Read Track 18 / Sector 2 into the buffer
                            for channel 5
PRINT#15,"B-P: 5 0"       ; Place Pointer at start of block
FOR I = 0 TO 253          ; One Block is max. 254 Byte
GET#5, A$                 ; Get another Byte
IF (ST <> 0) THEN ...     ; Check for End of Block
   ...                    ; Process Byte
NEXT I
CLOSE 5                   ; Close Channel
CLOSE 15                  ; Close Command Channel
BLOCK-WRITE - Write a Disk Block from the internal floppy RAM
Abbreviation: B-W
Syntax: "B-W:"+STR$(Channel)+STR$(Drive)+STR$(Track)+STR$(Sector)
Example:
OPEN 15, 8, 15            ; Open Command Channel
OPEN  5, 8, 5, "#"        ; Open Channel 5 to RAM buffer
PRINT#5, X$               ; Write some string
PRINT#5, Y$               ; Write another string
PRINT#5, Z$               ; Write yet another string
                                        (total: max. 254 Byte)
PRINT#15,"B-W: 5 0 18 2"  ; Write Track 18 / Sector 2 from
                                      the buffer for channel 5
CLOSE 5                   ; Close Channel
CLOSE 15                  ; Close Command Channel
BUFFER-POINTER - Set the pointer for a buffered block
Abbreviation: B-P
Syntax: "B-P:"+STR$(Channel)+STR$(Pos)
Example: see BLOCK-READ
BLOCK-ALLOCATE - Mark a disk block as used
Abbreviation: B-A
Syntax: "B-A:"+STR$(Drive)+STR$(Track)+STR$(Sector)
Example:
OPEN 1, 8, 15                ; Open Command Channel
PRINT#1,"B-A: 0 12 7"        ; Allocate Block at Track 12 Sector 7
INPUT#1, EN$, ER$, TR$, SC$  ; Get the sector that was allocated
CLOSE 1                      ; Close Command/Error Channel
PRINT "Track:;TR$;"Sector";SC$
BLOCK-FREE - Mark a disk block as unused
Abbreviation: B-F
Syntax: "B-F:"+STR$(Channel)+STR$(Pos)
Example:
OPEN 1, 8, 15                ; Open Command Channel
PRINT#1,"B-F: 0 12 7"        ; Free Block at Track 12 Sector 7
CLOSE 1                      ; Close Command/Error Channel
BLOCK-EXECUTE - Read a Disk Block into the internal floppy and execute it. Abbreviation: B-E
Syntax: "B-E:"+STR$(Channel)+STR$(Drive)+STR$(Track)+STR$(Sector)
Note: Block Execute obviously requires the complete emulation of the MOS 6502 CPU in the 1541. If you wish to use this command make sure that the Complete Floppy 1541 Emulation is enabled. Otherwise you will get a 'Command Not Emulated' Error Message.
USER1 - Read a Disk Block to the internal floppy RAM
Abbreviation: U1
USER1 works like BLOCK-READ with the exception that U1 considers the link to the next block to be part of the data. Thus a block read with U1 will be 256 (rather than max. 254) bytes long.
USER2 - Write a Disk Block from the internal floppy RAM
Abbreviation: U2
USER2 works like BLOCK-WRITE with the exception that U2 considers the link to the next block to be part of the data. Thus a block written with U2 has to be 256 (rather than max. 254) bytes long.
USER3..USER8 - Execute a User Program on the Floppy
Abbreviation: U3..U8
Program execution starts at $0500 + 3*(x-3) (i.e. $0500 for U3, $0503 for U4...)
Note: Block Execute obviously requires the complete emulation of the MOS 6502 CPU in the 1541. If you wish to use this command make sure that the Complete Floppy 1541 Emulation is enabled. Otherwise you will get a 'Command Not Emulated' Error Message.
USERI - Switch the C1541 between C64 to VC20 mode
Abbreviation: UI
Syntax: "UI+" or "UI-"
This is a dummy function in Power20. It causes a slight adjustment of transfer speeds on a real C1541
USERJ - Reset the C1541 to power-up condition
Abbreviation: UJ
Syntax: "UJ"
Substitute for INITIALIZE
MEMORY-READ - Read Data from the floppy RAM
Abbreviation: M-R (You must use the abbreviation, the full form is not legal).
Syntax: "M-R"+CHR$(LowAddress)+CHR$(HighAddress)+CHR$(Size)
Example:
OPEN 1, 8, 15                      ; Open Command Channel
PRINT#1, "M-R"+CHR$(52)+CHR$(18)+CHR$(3) ; Specify 3 Bytes
                                   ; starting at Addr. $1234
GET#1, A$, B$, C$                  ; Get all the Values at once!
CLOSE 1                            ; Close Channel
MEMORY-WRITE - Write Data to the floppy RAM
Abbreviation: M-W (You must use the abbreviation, the full form is not legal).
Syntax: "M-W"+CHR$(LowAddress)+CHR$(HighAddress)+CHR$(Size)
Example:
OPEN 1, 8, 15                 ; Open Command Channel
PRINT#1, "I"                  ; Initialize Floppy first !
PRINT#1, "M-W"+CHR$(52)+CHR$(18)+CHR$(8)
                              ; Specify Addr. $1234 and 8 Byte
PRINT#1, "POWER20"            ; Write 8 Byte (incl. CR)
CLOSE 1                       ; Close Channel
MEMORY-EXECUTE - Run a User Program on the Floppy
Abbreviation: M-E (You must use the abbreviation, the full form is not legal).
Syntax: "M-E"+CHR$(LowAddress)+CHR$(HighAddress)
Note: Memory Execute obviously requires the complete emulation of the MOS 6502 CPU in the 1541. If you wish to use this command make sure that the Complete Floppy 1541 Emulation is enabled. Otherwise you will get a 'Command Not Emulated' Error Message.
Home First Prev Contents Next Last Top of Page

Source: http://www.infinite-loop.at/Power20/Documentation/Power20-ReadMe/AB-Floppy_Commands.html
Power20 Homepage: http://www.infinite-loop.at and http://www.salto.at - EMail:
© Roland Lieger, Goethegasse 39, A-2340 Mödling, Austria - Europe
Last Changed: Feb. 29, 2008
Valid HTML 4.01!