|
|
|
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:
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
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
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
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$
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
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
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
|
|
|
|
|
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 |
|