background image

Summary of Contents for 1541-II

Page 1: ...COMMODORE 0 DISK DRIVE useris guide ...

Page 2: ......

Page 3: ...COMIVIODORE 1541 H DISK DRIVE USER S GUIDE ft commodore COMPUTERS ...

Page 4: ...iewed and is believed to be entirely reliable No responsibility however is assumed for inaccuracies The material in this manual is for information purposes only and may be changed without notice Commodore Electronics Ltd 1986 All rights reserved ...

Page 5: ...tenance tips 11 Chapter 2 Diskettes 12 What is a diskette 12 Safety rules for diskette care 13 Inserting a diskette 13 Safety rules for removing diskettes 14 Loading a packaged program 14 How to prepare a new diskette 15 Reusing an old diskette 16 Organizing a diskette library 17 Backups 17 Chapter 3 Directories 18 What is a directory 18 Viewing a directory 18 What a directory shows 18 Watch out f...

Page 6: ... 42 Opening a sequential file 42 Adding to a sequential file 45 Writing file data Print 46 Closing a file 48 Reading file data using INPUT 49 More about INPUT advanced 50 Numeric Data Storage on Diskette 51 Reading File Data Using GET 52 Demonstration of Sequential Files 54 Chapter 6 Relative Data Files 55 The value of relative access 55 Files Records and Fields 55 File limits 56 Creating a relati...

Page 7: ...apter 8 Internal Disk Commands 73 1541 Memory Map 73 Memory Read 74 Memory Write 75 Memory Execute 77 Block Execute 77 User commands 78 Chapter 9 Machine Language Programs 80 Disk related kernafl subroutines 80 Appendices A Changing the Device Number 81 B Error Messages 83 C Diskette Formats 87 D Disk Command Quick Reference Chart 92 E Test Demo Diskette 93 List of Figures 1 Front Panel 5 2 Back P...

Page 8: ......

Page 9: ...t records Direct File Access A third advantage of a disk drive is the ability to use relative files discussed in Chapter 6 On a diskette any part of a relative file can be accessed and altered separately without affecting the rest of the file Overall using a disk drive makes for easier and more powerful computing FEATURES OF THE 1541 The 1541 is one of the most affordable disk drives on the market...

Page 10: ...ation you need to use the 1541 effectively even if you know little or nothing about programming This part of the book tells you how to set up the system how to prepare diskettes for use how to read a directory and how to load programs Part two of the book is for advanced users and those who would like to become advanced users This part provides more advanced commands tells about the different file...

Page 11: ...e For the purpose of demonstration use the Test Demo diskette that was included with the disk drive If you run into any problems at this point refer to Chapter 2 Inserting a Diskette 3 Type LOAD HOW TO USE 8 forBasic2 DLOAD HOW TO USE for Basic 3 5 Press RETURN HOW TO USE is the name of a particular program on the Text Demo diskette To load a different BASIC program substitute the name of that pro...

Page 12: ...2 6522 VIA Versatile Interface Adapters Used for input and output and as internal timers 16116 RAM Random Access Memory Used as 2K of buffers 1 16KROM Read Only Memory Contains a 16K Disk Operating System DOS INTERFACE USED Commodore serial bus with two 6 pin DIN connectors Device number selectable from 8 11 Secondary addresses 0 15 PHYSICAL DIMENSIONS Height Width Depth 77 mm 184 mm 256 mm ELECTR...

Page 13: ...ve to the computer a demonstration diskette and a warranty card to be filled out and returned to Commodore Please don t connect anything until you ve read the next three pages It could save you a lot of trouble Figl Front Panel I POWER I DRIVE commodore 154W I FLOPPY DISK DRIVE I V 7 DOOR LEVER DRIVE INDICATER GREEN LED LIGHT ACTIVE FLASH ERROR POWER INDICATER RED LED LIGHT POWER ON THE PRODUCT DO...

Page 14: ...nt of the disk drive counter clockwise until it stops one quarter turn at most Then reach inside the long slot the lever covers when it points down and pull out any diskette you find there CONNECTING THE CABLES With the power supply the power cable plugs into the back of the disk drive at one end and into a grounded 3 prong outlet at the other end It will only go in one way Before you plug it in t...

Page 15: ...s disk drive like a daisy chain Fig 3 B However don t connect the other s until you ve learned how to change their device numbers as no two disk drives can have the same device number We ll cover ways of changing disk device numbers in Appendix A Until you are ready to read that section you may find it easier to leave your extra drive s unconnected TURNING ON THE POWER With everything hooked up an...

Page 16: ...al Computer Single Fig 3 A Floppy Disc Hookup Printer 1541 11 Single Drive Floppy Disk Power supply Printer Twin Fig 3 B Floppy Disc Hookup Power supply 1541 11 Single Drive Floppy Disk Commodore Personal Computer lAC ...

Page 17: ...eats try again power up before with the serial bus any disk commands disconnected If it have been given still repeats call your dealer If unplugging the serial cable made a difference check the cable for proper connection at both ends This can also be caused by some cartridges on the C 64 and always by a 16K cartridge on the VIC 20 Remove the cartridge and power up the disk drive again to determin...

Page 18: ...urred Follow the advice in Appendix B to correct it Be sure to spell program names exactly right as the disk drive is very particular even about spaces and punctuation marks and will not load a program unless you call it exactly the same thing it was called when it was saved on the diskette Your own programs Load fine but commercial programs and those from other 1541 owners fail to load Either the...

Page 19: ...r that excessive thumping especially when the drive is hot caused some older 1541 s to go out of alignment and led to costly repairs Current 1541 s have been redesigned to prevent the problem Note the Memory Write example in Chapter 8 temporarily turns off the bumps 4 It would be a good idea to have your 1541 checked over about once a year in normal use Several items are likely to need attention t...

Page 20: ...ece of tape This notch is called the write protect notch When it is covered with the opaque tape packed with blank diskettes the disk drive cannot change the contents of that diskette Never remove the tape on the Test Demo diskette The label on the top of the diskette says 1541 Test Demo on it and tells you which diskette you are using Blank diskettes come with extra labels in addition to one appl...

Page 21: ...ery difficult to rescue data from a diskette recorded with its hub off center One way to help center diskettes is to tickle the drive door shut instead of slamming it down By gently closing it part way and then opening a bit and then closing the rest of the way you give the spindle more chances to center the diskette properly Another way to ease diskette centering is to buy diskettes that come wit...

Page 22: ...efully insert the preprogrammed diskette as described on the previous page For purpose of demonstration use the Test Demo diskette included with the disk drive The following commands will load a program from the diskette into the computer BASIC 2 LOAD program name device number relocate flag Example LOAD HOW TO USE 8 BASIC3 5 DLOAD program name Ddrive Udevice number relocate flag Example DLOAD HOW...

Page 23: ...me Load command will also allow you to load other prepackaged programs from the Test Demo or other diskettes Merely substitute the exact program name that you want to use between the quotation marks in the above example and that will be the program the computer will load a list of Test Demo programs is shown in Chapter 3 in the section entitled What a Directory Shows Note here and in the remainder...

Page 24: ...is a 2 character diskette ID number drive is the drive number 0 if omitted as it must be on the 1541 and device is the disk s device number assumed to be 8 if omitted As described in the next page id is optional if and only if the diskette has been previously formatted on a 1541 Also the ID must be a string literal not a variable or expression and may not include Basic reserved words Thus IFI cann...

Page 25: ... use Therefore it is important to make regular backups of important programs and files Make a backup whenever you wouldn t want to redo your current work Just as you should save your work every half hour or so when writing a new program so you should also back up the diskette you re using at least daily while you are changing it frequently In a business you would make an archival backup every time...

Page 26: ...ample to load the entire directory from disk device 8 type LOAD T 8 Then to display the directory on your screen after it loads into computer memory type LIST You may slow the listing by pressing the CONTROL key on the VIC 20 and Commodore 64 and halt it entirely by pressing the STOP key You can also use this command to limit the directory to desired files by using pattern matching characters desc...

Page 27: ...e 0 If we had gotten this directory from a dual disk drive it might have said 1 instead The next thing on the top line of the directory after the format type is the name of the diskette enclosed in quotation marks and printed in reverse field Just as each program has a name so does the diskette itself assigned when the diskette was formatted The diskette name may be up to 16 characters long and se...

Page 28: ...apter 7 After all the directory entries have listed the directory finishes with a message showing how many blocks of the diskette are still available for use This number can vary from 664 on a new diskette to 0 on one that is already completely full WATCH OUT FOR SPLAT FILES One indicator you may occasionally notice on a directory line after you begin saving programs and files is an asterisk appea...

Page 29: ... will cause a SYNTAX ERROR in use The proper abbreviation for PRINT is pR READING A DIRECTORY AS A FILE If you would like to read a directory from within a program you may do so In Basic 3 5 simply include the DIRECTORY command in your Basic program In Basic 2 however and optionally in the others you will have to Open the directory as though it were a data file and read it character by character S...

Page 30: ...he question mark only makes its own character position wild Here are some examples and their results LOAD A 8 loads the first file on disk that begins with an A regardless of what follows ARTIST ARTERY and AZURE would all qualify but BARRY wouldn t even though it has an A elsewhere in its name DLOAD SM7TH Basic 3 5 loads the first program that starts with SM ends with TH and has one other characte...

Page 31: ... the disk commands whose format includes a pattern This applies to Load Dload Directory Open Scratch and to the source file in the Copy and Rename commands More than one can appear in the same pattern As you might expect their use in pattern matching means you can t use the asterisk or question mark in a file name when saving or writing a file see next chapter 23 ...

Page 32: ......

Page 33: ... disk drive and Basic s Input command to receive information back from the disk drive These two commands are like Basic s Print and Input statements except that they use the device number specified in the preceding Open statement instead of defaulting to the screen and keyboard respectively In Basic 2 you ll use both Print 15 and Input 15 extensively to send housekeep ing commands to the disk and ...

Page 34: ...at the INPUT command cannot easily be used in immediate mode that is without a line number You will often need to be able to read the disk error channel to see why the disk error light is flashing and thereby turn the error light off again Here is a brief program to check for disk errors 10J3PEN 15 8 15 20 INPUT 15 EN EM ET ES 30 PRINT EN EM ET ES 40 CLOSE 15 This little program reads the error ch...

Page 35: ...will be closed somewhere else at the end of the program This subroutine reads the error channel and puts the results into the named variables In the Basic 2 version they are EN EMS ET and ES which stand for Error Number Error Message Error Track and Error Sector respectively Of the four only EM has to be a string and you could choose other variable names although these have become traditional for ...

Page 36: ...mands when you turn on your computer This is a handy way to check which version of DOS you are using However if this message appears later after other disk commands it means there is a mismatch between the DOS used to format your diskette and the DOS in your drive HINT 4 To reset drive type OPEN 15 8 15 UJ Then wait until the drive activity LED is off and motor goes off then type CLOSE 15 This als...

Page 37: ...arameter If omitted the drive number defaults to 0 and the device number to 8 However it will not work in copying programs that are not in the Basic text area such as DOS 5 1 for the Commodore 64 To copy it and similar machine language programs you will need the S command of the machine language monitor built into the Commodore 16 and Plus 4 To access a built in monitor type MONITOR To exit a moni...

Page 38: ...off midway through the process would destroy both the old and new copies of the file Nothing happens to the old copy until after the new copy is saved properly However we do offer one caution do not use Save on an almost full diskette Only use it when you have enough room on the diskette to hold a second complete copy of the program being replaced Due to the way Save works both the old and new ver...

Page 39: ...th replace because the last file used was the one deleted and the drive will try to compare the deleted file to the program in memory No harm will result but VERIFY ERROR will always be announced To use verify after SAVE include at least part of the file name that is to be verified in the pattern One other note about Verify when you Verify a relocated file an error will nearly always be announced ...

Page 40: ...T TRAIN TRUCK and TAIL you may scratch all four along with any other files beginning with the letter T by using the command PRINT 15 S0 T Then to prove they are gone you can type GOSUB 59990 to call the error checking subroutine given earlier in this chapter and if the four listed were the only files beginning with T you will see 01 FILES SCRATCHED 04 00 READY The 04 tells you 4 files were scratch...

Page 41: ...e 01 FILES SCRATCHED 04 00 READY The 04 tells you 4 files were scratched SCRATCH FOR ADVANCED USERS Scratch is a powerful command and should be used with caution to be sure you only delete the files you really want erased When using it with a pattern we suggest you first use the same pattern in a Directory command to be sure exactly which files will be deleted That way you ll have no unpleasant su...

Page 42: ... diskette If the numbers match no damage has been done If not very likely at least one file on the diskette has been corrupted and all should be immediately checked Locked Files Very occasionally a diskette will contain a locked file that is one which cannot be erased with the Scratch command Such files may be recognized by the character which immediately follows the file type in their directory e...

Page 43: ...ME COMMAND RENAME old name TO new name Ddrive Udevice where new name is the name you want the file to have and old name is the name it has now new name may be any string expression that evaluates to a valid file name up to 16 characters in length If D is left out drive 0 is assumed If U is absent clevice 8 is assumed One caution be sure the file you are renaming has been properly closed before you...

Page 44: ...on to specify troublesome characters without typing them directly This may allow you to build them into a Rename command If this fails you may also use the pattern matching characters in a Scratch command This gives you a way to specify the name without using the troublesome characters at all but also means loss of your file For example if you have managed to create a file named MOVIES with an ext...

Page 45: ...NT 15 4C0 BACKUP ORIGINAL where 4 drive is the drive number 0 on the 1541 t4new file is the copy and 4 old file is the original FORMAT FOR THE CONCATENATE OPTION PRINT 15 44Cdrive new file drive file l drive file 2 drive file 3 drive file4 where 44drive is the drive number for each file Since it is always 0 on the 1541 the drive number is often omitted EXAMPLES After renaming a file named 4 BOOT t...

Page 46: ... the last section s example we can use the Copy command to make a spare copy of the program elsewhere on the diskette under the original name COPY TEMP TO BOOT To copy a file on a second disk drive we would use COPY ORIGINAL TO BACKUP U9 NOTE Dual drives make fuller use of this command copying programs from one diskette to another in a single disk unit To do that on the 1541 refer to Appendix E to...

Page 47: ...ng used by valid properly closed files and programs All other sectors blocks are left unallocated and free for re use and all improperly closed files are automatically Scratched However this bare description of its workings doesn t indicate either the power or the danger of the Collect command Its power is in restoring to good health many diskettes whose directories or block availability maps have...

Page 48: ...diskette is inserted The optical write protect switch is used to sense when a diskette is changed The result of an Initialize whether forced by a command or done automatically by the disk is a re reading of the current diskette s BAM Block Availability Map into a disk buffer This information must of course always be correct in order for the disk to store new files properly However since the chore ...

Page 49: ...egular basis under normal conditions of cleanliness and care Nonetheless if you are using such a kit the following short program will keep the diskette spinning long enough for your need 10 OPEN 15 8 15 20 FOR 1 1 TO 99 30 PRINT 15 I0 40 NEXT 50 CLOSE 15 It uses an Initialize loop to keep the drive motor on for about 20 seconds 41 ...

Page 50: ...rn some more Basic words in the next few pages Then we ll put them together in a simple but useful program Note Besides sequential data files two other file types are recorded sequentially on a diskette and may be considered varying forms of sequential files They are program files and user files When you save a program on a diskette it is saved in order from beginning to end just like the informat...

Page 51: ...arned how to check for disk errors after disk com mands in a program It is equally important to check for disk errors after using file handling statements Failure to detect a disk error before using another file handling statement could cause loss of data and failure of the Basic program The easiest way to check the disk is to follow all file handling statements with a Gosub statement to an error ...

Page 52: ...n is the type of access desired There are three possibilities R read W write and M modify When creating a file use W to write the data to diskette When viewing a completed file use R to read the data from diskette Only use the M modify option as a last ditch way of reading back data from an improperly closed Splat file If you try this check every byte as it is read to be sure the data is still val...

Page 53: ...00 120 OPEN 4 8 2 PHONE STR PH S R You can omit the drive number on an Open command to read a file Doing so allows those with dual drives to search both diskettes for the file Note Basic 2 and Basic 3 5 use the same file handling commands and the same direct access commands chapters 7 8 Unless otherwise noted you may use the same commands for both throughout the remainder of this book ADDING TO A ...

Page 54: ...s i e with CLOSE 15 WRITING FILE DATA USING PRINT After a sequential file has been opened to write with a type and direction of S W we use the Print command to send data to it for storage on diskette If you are familiar with Basic s Print statement you will find Print works exactly the same way except that the list of items following the command word is sent to a particular file instead of automat...

Page 55: ... following a numeric variable Note Do not leave a space between PRINT and and do not abbreviate the command as The correct abbreviation for Print is pR EXAMPLES To record a few grades for John Paul Jones using a sequential disk file 1 previously opened for writing we could use 200 FOR CLASS 1 TO COURSES 210 PRINT 1 GRADE CLASS 220 NEXT CLASS 320 GOSUB 59990 REM CHECK FOR DISK ERRORS assuming your ...

Page 56: ...ity Map of sectors used by the current file which are not performed during the ordinary course of writing a file This is the reason for having a Close statement When we know we are done with a file the Close statement will write the rest of the data buffer out to cassette or diskette update the BAM and complete the file s entry in the directory Always Close a data file when you are done using it F...

Page 57: ...t accepting data items too large to fit in Basic s Input buffer and not accepting non numeric data into a numeric variable FORMAT FOR THE INPUT STATEMENT PRINT file variable list where file is the same file number given in the desired file s current Open statement and variable list is one or more valid Basic variable names If more than one data element is to be input by a particular Input statemen...

Page 58: ...occurred FILE DATA ERRORS The other error message FILE DATA ERROR is caused by attempting to read a non numeric character into a numeric variable To a computer a number is the characters 0 through 9 the an3 signs the decimal point the SPACE character and the letter E used in scientific notation If any other character appears in an Input to a numeric variable FILE DATA ERROR will be displayed and t...

Page 59: ... type is written to a file the space it occupies depends entirely on its length not its type Numeric data is written to a file in the form of a string as if the Str function had been performed on it The first character will be a blank space if the number is positive and a minus sign if the number is negative Then comes the number digit by digit The last character is a cursor right character This f...

Page 60: ...s used rather than additional variables Also as in the Input statement it is safer to use string variables when the file to be read might contain a non numeric character Data in a Get statement comes in byte by byte including such normally invisible characters as the Carriage Return and the various cursor controls All but one will be read properly The exception is CHR 0 the ASCII Null character It...

Page 61: ...file and the one that loops back to read again For example it would be required if line 520 was changed to 520PRINT l S Otherwise the file status checked in line 530 would be that of the write file not the read file POSSIBLE VALUES OF THE FILE STATUS VARIABLE t4ST IFST 0 1 2 4 8 16 32 64 128 AND THEIR MEANINGS THEN All is OK Receiving device was not available time out on talker Transmitting device...

Page 62: ...UT 2 A B 400RS ST 410 GOSUB 500 420 PRINT A B 430 IF RS 0 THEN 390 440 IF RSO64 THEN PRINTt4STATUS RS 450 CLOSE 2 460 END 480 REM ERROR CHECK S R 500 INPUT 15 EN EM ET ES 510 IF EN 0 THEN PRINT EN EM ET ES STOP 520 RETURN first experiments with sequential files better understand it Make a carriage return variable Open demo file with replace Check for disk errors Accept a string number from keyboar...

Page 63: ...for our data The structure we will use is similar to that used in the traditional filing cabinet In a traditional office all customer records might be kept in a single file cabinet Within this file each customer has a personal record in a file folder with their name on it that contains everything the office knows about that person Likewise within each file folder there may be many small slips of p...

Page 64: ...aturally the entire file also has to fit on your diskette too which means that the more records you need the shorter each must be CREATING A RELATIVE FILE When a relative file is to be used for the first time its Open statement will create the file after that the same Open statement will be used to reopen the file for both reading and writing FORMAT STATEMENT TO OPEN A RELATIVE FILE OPEN file devi...

Page 65: ...t quite ready for use Both to save time when using the file later and to assure that the file will work reliably it is necessary to create several records before closing the file for the first time At a minimum enough records to fill more than 2 disk sectors 512 bytes should be written In practice most programs go ahead and create as many records as the program is eventually expected to use That a...

Page 66: ...ritten with the Commodore Assembler the low part of a two byte number is indicated by preceding its label with the less than character Similarly the high part of the number is indicated by greater than SAFETY NOTE GIVE EACH RECORD COMMAND TWICE To avoid the remote possibility of corrupting relative file data it is necessary to give Record commands twice once before a record is read or written and ...

Page 67: ...offset is as above If you see a Record command written in Basic 4 form in a program you want to use simply convert it into the usual form for both Basic 2 and 3 5 described in this section COMPLETING RELATIVE FILE CREATION Now that we have learned how to use both the Open and Record commands we are almost ready to properly create a relative file The only additional fact we need to know is that CHR...

Page 68: ...ximum record number you selected in line 1390 This is normal and only needs to be done once During the process you may hear the drive motor turning and an occasional slight click as the head steps from track to track everything is probably just fine Second line 60000 above is different from the equivalent line in the error check subroutine given earlier Here disk error number 50 is specifically ig...

Page 69: ...n without a finahcarriage return Though the saving of a single character isn t much when multiplied by the number of records on a diskette the savings could be significant Since each relative record must be written by a single Print statement the recom mended approach is to build a copy of the current record in memory before writing it to disk It can be collected into a single string variable with...

Page 70: ...LEN ZP 10 THEN 2060 2080 DAS NA CR SA CR CS CR ZP 2090 IF LEN DA 87 THEN 2120 2100 PRINT44RECORD TOO LONG 2110 GOTO 2000 2120RH INT RE 256 2130RL RE 256 RH 2140 PRWT 15 44F CHR 96 3 CHR RL CHR RH 2150 GOSUB 59990 2160PRINT 3 DA 2170 GOSUB 59990 2180 PRINT 15 44P CHR 96 3 CHR RL CHR RH 2190 GOSUB 59990 Carriage Return Enter fields And check length of each Build output data string Check its length I...

Page 71: ...is written DOS overwrites any remaining spaces in the record Thus if you must use the offset option never update any field in a record other than the last one unless all succeeding fields will also be updated from memory later The above programs are careful to match record lengths exactly to the space available Programs that don t do so will discover that DOS pads short records out to full size wi...

Page 72: ...plete RELATIVE FILE program similar to the examples in this chapter is included on the Test Demo diskette THE VALUE OF INDEX FILES ADVANCED USERS In the last two chapters we have learned how to use sequential and relative files separately But they are often used together with the sequential file used to keep brief records of which name in the relative file is stored in each record number That way ...

Page 73: ...centric circles on the surface of the diskette There are 35 different tracks starting with track 1 at the outside of the diskette to track 35 at the center Track 18 is used for the directory and the DOS fills up the diskette from the center outward alternately in both directions Each track is subdivided into sectors also called blocks Because there is more room on the outer tracks there are more s...

Page 74: ...t one OPEN5 8 5 Or we can make the choice ourselves OPEN4 8 4 2 BLOCK READ The purpose of a Block Read is to load the contents of a specified sector into a file buffer Although the Block Read command B R is still part of the DOS command set it is nearly always replaced by the Ul command FORMAT FOR THE BLOCK READ COMMAND PRINT 15 Ul channel drive track sector where channel is the channel number spe...

Page 75: ...er memory beginning at the address set by variable MB in line 160 and may be examined and altered there This is the basis for programs like DISPLAY T S on the Test Demo diskette BLOCK WRITE The purpose of a Block Write is to save the contents of a file buffer into a specified sector It is thus the reverse of the Block Read command Although the Block Write command B W is still part of the DOS comma...

Page 76: ...rly always replaced by the Ul and U2 commands respectively the original commands can still be used as long as you fully understand their effects Unlike Ul and U2 B R and B W allow you to read or write less than a full sector In the case of B R the first byte of the selected sector is used to set the buffer pointer see next section and determines how many bytes of that sector are read into a disk m...

Page 77: ... pointer and only that many bytes are written into the specified sector It cannot be used to rewrite an entire sector onto diskette unchanged because the first data byte is overwritten by the buffer pointer THE BUFFER POINTER The buffer pointer points to where the next Read or Write will begin within a disk memory buffer By moving the buffer pointer you can access individual bytes within a block i...

Page 78: ...rogram but substitute the revised line 160 below to unlock the file again 160 A ASC A AND 191 Turn off bit 6 to unlock ALLOCATING BLOCKS Once you have written something in a particular sector on a diskette with the help of direct access commands you may wish to mark that sector as already used to keep other files from being written there Blocks thus allocated will be safe until the diskette is val...

Page 79: ... END FREEING BLOCKS Open command channel direct access Write a message to buffer Start at first track sector Try allocating it See if it worked If so we re almost done NO BLOCK means already allocated If next track is 0 we re out of room Don t allocate the directory Try suggested track sector next Write buffer to allocated sector Say where message went and tidy up The Block Free command is the opp...

Page 80: ...o keep track of which blocks on the disk such a file has used Even though you know a sector has not been allocated by your random file you must also be sure it wasn t allocated by another unrelated file on the diskette The most common way of recording which sectors have been used by a random file is in a sequential file The sequential file stores a list of record numbers with the track sector and ...

Page 81: ... drive off and on again after removing the diskette to regain control Do not practice these commands on any important diskette Rather make a spare copy and work with that Knowing how to program a 6502 in machine language will help greatly and you will also need a good memory map of the 1541 A brief 1541 map appears below Location 0000 00FF 0100 01FF 0200 02FF 0300 07FF 1800 180F 1C00 1C0F C100 F25...

Page 82: ...ote Unlike other disk commands those in this chapter cannot be spelled out in full Thus MR is correct but MEMORY READ is not a permitted alternate wording FORMAT FOR THE MEMORY READ COMMAND PRINT 15 t4M R CHR address CJ4R address CHR of bytes where address is the low order pari and address is the high order part of the address in disk memory to be read If the optional t4 of bytes is specified it s...

Page 83: ... Check bits 0 5 and give results Tidy up after Here s a more general purpose program that reads one or more locations anywhere in disk memory 110OPEN15 8 15 120 INPUT OF BYTES TO READ 0 END NL 130 IF NL 1 THEN CLOSE 15 END 140IFNL 255THEN120 150 INPUT STARTING AT ADDRESS AD 160 AH INT AD 256 AL AD AH 256 170PRINT 15 M R CHR AL CHR AH CHR NL 180 FOR 1 1 TO NL 190 GET 15 A IF A THEN A CHR 0 200 PRIN...

Page 84: ...not be read normally PRINT 15 ttM W CHR 106 CHR 0 CHR l CHR 31 The above two examples may be very useful under some circumstances They are the equivalent of POKE 106 133 and POKE 106 31 respectively but in disk memory not inside the computer As mentioned in the previous section s first example location 106 in the 1541 disk drive signifies three separate activities to the drive all related to error...

Page 85: ...ld be to artificially trigger an errat message Don t forget to check the error channel or you ll miss the message PRIOT 15 M E CHR 201 CHR 239 However most uses require intimate knowledge of the inner workings of the DOS and preliminary setup with other commands such as Memory Write BLOCK EXECUTE This rarely used command will load a sector containing a machine language routine into a memory buffer...

Page 86: ...ad and Block Write commands UI re starts the 1541 without changing its variables UJ cold starts the 1541 almost as if it had been turned off and on again and UI speeds up the 1541 when used with the VIC 20 only Note VIC 20 owners don t have to use UI the 1541 works with the VIC 20 with or without this command User Command Function UI or UA replaces Block Read U2 or UB replaces Block Write U3 or UC...

Page 87: ... USER COMMANDS PRINT 15 Ucharacter where character defines one of the preset user commands listed above EXAMPLES PRINT 15 U Preferred form of DOS RESET command PRINT 15 U3 Execute program at start of buffer 2 79 ...

Page 88: ...T END LDA LDX LDY JSR LDA LDX LDY JSR JSR LDX JSR JSR BEQ JSR JMP LDA JSR JSR RTS FFBA FFBD FFC0 FFC3 FFC6 FFC9 FFCC FFCF FFD2 4 FNADR FNADR SETNAM 3 8 0 SETLFS OPEN 3 CHKIN CHRIN END CHROUT NEXT 3 CLOSE CLRCHN SET LOGICAL FIRST SECOND ADDRESSES SET LENGTH ADDRESS OF FILENAME OPEN LOGICAL FILE CLOSE LOGICAL FILE SELECT CHANNEL FOR INPUT SELECT CHANNEL FOR OUTPUT CLEAR ALL CHANNELS RESTORE DEFAULT ...

Page 89: ...umber from 8 11 10 INPUT NEW DEVICE NUMBER DV 20 IF DV 8 OR DV 11 THEN 10 30 OPEN 15 8 15 40 PRINT 15 M W CHR 119 CHR 0 CHR 2 CHR DV 32 CHR DV 64 50 CLOSE 15 Note If you will be using two disk drives and want to temporarily change the device number of one you will need to run the above program with the disk drive whose device number is not to be changed turned off After the program has been run yo...

Page 90: ...BER USING THE SWITCH 1 Turn off the disk drive 2 Refer to the following chart to set the DIP SW at the back of the disk drive for device number setting Device swl sw2 8 9 10 11 ON OFF ON OFF ON ON OFF OFF 3 Turn on the disk drive 82 ...

Page 91: ...ther error message numbers less than 20 ever appear they may be ignored All true errors have numbers of 20 or more 20 READ ERROR block header not found The disk controller is unable to locate the header of the requested data block Caused by an illegal block or a header that has been destroyed Usually unrecoverable 21 READ ERROR no sync character The disk controller is unable to detect a sync mark ...

Page 92: ...c mark of the next header after writing a data block If the sync mark does not appear on time this error message is generated It is caused by a bad diskette format the data extends into the next block or by a hardware failure 29 DISK ID MISMATCH The disk controller has been requested to access a diskette which has not been initialized Can also occur if a diskette has a bad header 30 SYNTAX ERROR g...

Page 93: ...ons in the data to allow shorter records 60 WRITE FILE OPEN A write file that has not been closed is being re opened for reading This file must be immediately rescued as described in Housekeeping Hint 2 in Chapter 4 or it will become a splat improperly closed file and probably be lost 61 FILE NOT OPEN A file is being accessed that has not been opened by the DOS In some such cases no error message ...

Page 94: ...FULL is sent when 2 blocks are still available allowing the current file to be closed If you get this message and the directory shows any blocks left you have too many separate files in your directory and will need to combine some delete any that are no longer needed or copy some to another diskette 73 DOS MISMATCH CBM DOS V2 6 1541 If the disk error status is checked when the drive is first turne...

Page 95: ...ot to scale snt til iuiii lUtl ii ueii neti iirai hiiii him Wllll ii cuutni limit ii cuutni huh i w ITTI 10 ITTI ItltU Itf tm uu un IKl ii HI un imt un Illtt toe ini toe ini inti ucni ur 1541 Format Expanded View of a Single Sector 87 ...

Page 96: ...541 4040 format Null flag for future DOS use Bit map of the available blocks in tracks 1 35 1 available block 0 block not available each bit represents one block 1541 DIRECTORY HEADER Track 18 Sector 0 BYTE 144 159 160 161 162 163 164 165 166 167 170 170 255 CONTENTS 160 160 50 65 160 0 DEFINITION Diskette name padded with shifted spaces Shifted spaces Diskette ID Shifted space ASCII representatio...

Page 97: ... tokenized FINAL SECTOR 0 1 Null 00 followed by number of valid data bytes in sector 2 Last bytes of the program information stored as in computer memory with key words tokenized The end of a Basic file is marked by 3 zero bytes in a row Any remaining bytes in the sector are garbage and may be ignored SEQUENTIAL FILE FORMAT BYTE DEFINITION ALL BUT FINAL SECTOR 0 1 Track and sector of next sequenti...

Page 98: ...s 00 SIDE SECTOR BLOCK 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 255 Track and sector of next side sector block Side sector number 0 5 Record length Track and sector of first side sector number 0 Track and sector of second side sector number 1 Track and sector of third side sector number 2 Track and sector of fourth side sector number 3 Track and sector of fifth side sector number 4 Track and secto...

Page 99: ... 20 21 22 25 26 27 28 29 CONTENTS 128 type DEFINITION File type OR ed with 80 to indicate properly closed file if OR ed with SCO instead file is locked TYPES 0 DELeted 1 SEQuential 2 PROGram 3 USER 4 RELative Track and sector of first data block File name padded with shifted spaces Relative file only track and sector of first side sector block Relative file only Record length Unused Track and sect...

Page 100: ...me SCRATCH file name COLLECT 10 LOAD file name 8 SAVE 0 filename 8 DLOAD file name DSAVE file name CLOSE file GET file variable list INPUT file variable list OPEN file 8 channel 0 file name file type direction PRINT file data list P CHR channel CHR record CHR record CHR offset DIRECT ACCESS COMMANDS BLOCK ALLOCATE BLOCK EXECUTE BLOCK FREE BUFFER POINTER BLOCK READ BLOCK WRITE MEMORY EXECUTE MEMORY...

Page 101: ... check the mechanical and electronic capabilities of the printer DISK ADDR CHANGE Use this program to change the device number of the disk drive It is a soft change when the system is turned off the disk drive is reset to its original device number VIEW BAM The VIEW BAM program allows a programmer to examine the contents of the sec tors that make up the block availability map BAM the table that DO...

Page 102: ...ting of reverse video and graphics characters depends on the specific printer model used These programs can run from tape C64 BASIC DEMO 4 BASIC DEMO These programs offer a set of demo routines which can perform minimal system testing on the computers Routines are provided for testing the video and sound output keyboard and joy stick input and disk unit I O LOAD ADDRESS LOAD ADDRESS is a simple pr...

Page 103: ......

Page 104: ...r PA 193B0 Commodore Business Machines Lid 3470 Pharmacy Avenue Agmcourl Ontario M1W 3G3 Commodore is a legialured tT adorn iirk qI Commodo e EleCTromcs Limitt d CammoclDre 1 JlCia a raftomark at Commnnnrc ElcclroniCii I imilotl PRINTED IN TAIWAN P N 3E413S 01 41A081 O01 ...

Reviews:

Related manuals for 1541-II