C-128 Boot Sectors


This article originally appeared in issue #27, 1990, of SPRITE, the former newsletter of the Commodore User's Group of the Boston Computer Society. The newsletter is no longer printed.

    
            Yes, you CAN have more than one boot sector on a C-128
     disk! ...well, sort of!
            In addition to the normal boot sector found at track 1, sector
     0, there are other ways to auto load/execute files in the C-128 mode.
     When you power up your C-128 with a disk in drive #8 there are several
     routines the machine goes through before entering Basic.
     
      1)  The C-128 enters the Kernal's BOOT CALL routine which searches
      routine which searches
     for the 'CBM' signature as the first three bytes of track 1, sector 0.
     Not finding these, it returns to Basic.
      2)  If 'CBM' exists the sector is read into the cassette buffer at
     $0b00 in Bank 0, where the contents are read.
      3)  If the byte at $0b06 is not zero the computer will read more
     blocks starting at track 1, sector 1 and place them into memory
     starting at the address indicated by bytes $0b03-$0b04, in the Bank
     indicated by $0b05. This is the method that the program KeyBoot uses
     to load in your function key configuration on boot-up.
      4)  Now the 128 prints the BOOTING message on the screen followed by
     whatever is at byte $0b07 until the next zero byte. If there is a
     filename following the zero byte the machine will attempt to load it.
      5)  After the filename (if it exists) there will be another zero byte
     followed by a short machine language program which usually calls RUN
     A PROGRAM (JMP$af99), or EXECUTE A LINE (JMP$afa5).
      6)  If you have a 1581, there is another trick up your sleeve! During
     the initialization process of the disk drive, or power up, the drive
     will load the first file on the disk with the name 'COPYRIGHT CBM 86'
     into it's own internal memory and execute it before the computer can
     boot. This has to be a User type file with a special format.
     
     AUTO BOOT LOADER
         In the UsER
         In the User's Guide to the 1581 disk drive there is a reference to
     the Auto Boot Loader. This is the COPYRIGHT CBM 86 (USR) file
     mentioned above. The first two bytes of this file must contain a low
     and high address where in disk RAM the program is to be loaded. The
     third byte is the number of bytes to follow. The last byte is a
     checksum. This autobooted program should give control back to the 1581
     through the JCBMBOOTRTN vector at $ff5a which disables it so it
     doesn't run again. The interesting thing here is that DOS commands to
     the 1581 are vectored through a table in RAM that points to the
     routines in ROM. By changing these pointers you can change how the
     drive works. For example, by changing a pointer to an RTS you can
     disable the Format/New command, or the SCRATCH command. I have
     included a simple Basic program that writes such a file that will turn
     off the INITIALIZE command. Frequently in commercial and other
     software usually written for 1541 and 1571 drives the "IO" command is
     issued every time there is a disk operation. If you want to use a
 want to use a
     partitioned 1581 disk you may be in trouble because an "IO" will send
     you right back to the root directory.
 
     
     UTILITY LOADER
         This is not really a "boot" file, but it is structured almost
     exactly like the Auto Boot File and also works only in disk RAM. The
     only difference is that it should end with an RTS before the checksum
     byte. It is not "booted" but rather called. The command is:
            PRINT#15,"&:filename"
     
         It will load, execute, and return to Basic. This can be done in
     either immediate or program mode. For instance you could call one file
     to turn the SCRATCH command on, and then call another one to turn it
     off. I have included a few samples that will write such programs to
     disk.
     
     BOOT SECTOR EXAMPLE
     
     $00 - CBM              ;signature
     $03 - $00,$10,$00,$01  ;other BOOT sector
                                            :starts at $1000, Bank 0
                                            :one block in size 
     $07 - NAME,$00         ;message "NAME",delimiter 
     $0c - PROGRAM,$00      ;filename,delimiter  
     $24 - $a2,$2b          ;ldx #$2b       :set pointer to start of  
     $26 - $a0,$0b          ;ldy #$0b       :line of Basic ($0b2b) and 
     $28 - $4c,$a5,$af      ;jmp $afa5      :Jump to routine at $afa5 
     $2b - RUN"PROGRAM"     ;line of Basic data  
     $36 - $00  asic data  
     $36 - $00              ;zero byte delimiter
     
     
     "OTHER" (or BINARY) BOOT SECTOR(S) starting at Track 1, Sector 1
     
     $00 - data or binary code loaded into a specified part of memory as if
     BLOADed. This code is not executed. Note that there are no track and
     sector links in the first two bytes even if the code is longer than
     one block. This is because the DOS already knows how to trace the
     data. If the code IS longer than one block, the last byte of each
     block must be a checksum for that block.
     
     
     AUTO BOOT LOADER (filename "COPYRIGHT CBM 86")
     
     $00 -  Track, Sector links  
     $02 -  Low, High address in disk RAM where this code will start  
     $04 -  Length of ml code in this sector  
     $05 -  user ml code  
     end-3  $4c,$$5a,$ff    :JMP JCBMBOOTRTN    :returns control to 1581
     end+1  checksum        :bytes 2 through end are added,
                            :then the low and high bytes are
                            :added
     
     
     UTILITY LOADER (filename "filename")
                    (loads and executes w/ PRINT#15,"&:filename")  
     
     $00 -  Track, Sector links  
     $02 -  Low, High address in disk RAM where this code will start  
     $04 -  Length of ml code in this sector  
     $05 -  user ml code  
     end -  $60             :JSR                :returns control to Basic 
     end+1  checksum   o Basic 
     end+1  checksum        :bytes 2 through end are added,
                            :then the low and high bytes are
                            :added
     
     
           One of the more annoying things about the way Commodore writes
     it's user manuals is it's inability to tell you the whole story. On
     page 108 of the 1581 User's Guide is a Jump Table showing the ROM
     locations of drive routines. They tell you that the indirect vectors
     are located in RAM. But they don't tell you where. Here's where:
     
     Name            ROM location         RAM vector
     -----------------------------------------------
     JIDLE           $FF00                $0190
     JIRQ            $FF03                $0192
     JNMI            $FF06                $0194
     JVERDIR         $FF09                $0196
     JINTDRV         $FF0C                $0198
     JPART           $FF0F                $019A
     JMEM            $FF12                $019C
     JBLOCK          $FF15                $019E
     JUSER           $FF18                $01A0
     JRECORD         $FF1B                $01A2
     JUTLODR         $FF1E                $01A4
E                $01A4
     JDSKCPY         $FF21                $01A6
     JRENAME         $FF24                $01A8
     JSCRTCH         $FF27                $01AA
     JNEW            $FF2A                $01AC
     
     
     All this material was gleaned out of various publications including:
           Commodore 1581 User's Guide
           DOS File Executor by Chris Johnsen
                            Transactor Vol. 6, Issue 1
           Disabling "i0" on the 1581 by Miklos Garamszegy
                            Transactor Vol. 9, Issue 2
           COMPUTE!'S 128 Programmer's Guide
           Commodore 128 Programmer's Reference Guide
     
     I thought it would be helpful to have all this stuff in ONE place!!!
     
     NOTE: While most of this discussion has been about the 1581 in concert
     with a C-128 computer, not all this stuff is drive or computer
     specific! For example, the Utility Loaders will work in C64 mode
     exactly the same as C-128 mode. All but the Auto Boot Loaders will
     work with a 1541. I suspect the same is true of a 1571. However the
     code for a 1541, or 1571 Utility Loader file is necessarily different
     than what you'd have for a 1581. Curiously, if you happen to own a
     1541 produced before 1984 with an old version of ROM $E000-$FFFF, you
     may have the ability to boot a Utility Loader on power-up. This older
     ROM carries the number 901229-03. If the Datmber 901229-03. If the Data and Clock lines of the
     serial bus were grounded at power-up the drive would jump to a routine
     in ROM and wait until the ground was lifted and then load and execute
     the first file on the disk. Later versions eliminated the code.
     
     1/23/90
     
                      Geoff Sullivan
 
 
    Enclosed are some sample files archived in SFX form.
    I use one to disable "i0" when using Desterm, since it calls "i0"
    every time there is a disk access, and that blows me out of
    partitions, back to the root directory.
 
 
CONTENTS
 
    These files will write an Auto Boot Loader "copyright cbm 86" file to
    your 1581 disk that will turn off the respective functions of your
    drive on power-up. Obviously, you can only have one on each disk.
 
             "copyrght io-off"   
             "copyrght collect"  
             "copyrght scratch"  
             "copyrght new"      
 
    These files will write Utility Loaders for your 1581 disks.
 
             "1581.& ex-io"      
             "1581.& ex-collct"  
             "1581.& ex-scrtch"  
             "1581.& ex-new"     
 
    This file will write a Utility Loader for the 1541.
 
             "1541.& chg to 9    
 
 

Send comments to me.
Back to the C= Computer Connection
Re-Connect