1540 Autoload

Started by Hydrophilic, January 17, 2010, 01:46 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Hydrophilic

There seems to be some confusion with the 1540 "autoload" feature, so I thought I should clarify the issue.  Many of the posts I quote come from this thread.

Quote from: cbm-iiI believe the Commodore 128 was the first C= machine to support auto-booting from a disk...

The C128 was the first CBM computer that will auto-boot a file (AFIAK).  However, the C1540 (maybe 1541?) is a disk drive that will auto-boot.  This works very much like the poorly-documented "&" command...

On power-up (see /RESET vector $FFFC -> $EAA0), the 1540 (maybe 1541) will auto-load and -execute the first file on disk (filename "*") if both /CLK and /DATA are active (grounded to zero volts) when the device powers up.

Quote from: 1540 ROM (reset code)
.8:e780   AD 00 18   LDA $1800
.8:e783   AA         TAX
.8:e784   29 04      AND #$04
.8:e786   F0 F7      BEQ $E77F
;/CLK active, test /DATA
.8:e788   8A         TXA
.8:e789   29 01      AND #$01
.8:e78b   F0 F2      BEQ $E77F
;both /DATA and /CLK active
;wait until both inactive...
.8:e78d   58         CLI
.8:e78e   AD 00 18   LDA $1800
.8:e791   29 05      AND #$05
.8:e793   D0 F9      BNE $E78E
;both /DATA and /CLK inactive, boot file "*"
.8:e795   EE 78 02   INC $0278
.8:e798   EE 74 02   INC $0274
.8:e79b   A9 2A      LDA #$2A    ;*
.8:e79d   8D 00 02   STA $0200 ;set filename
.8:e7a0   4C A8 E7   JMP $E7A8 ;do & command on file *

This code also appears in the 1541 ROM that comes with VICE.  I no longer own a C1541 (destroyed many years ago), and I never owned a C1540 (although some friends had them back in the day)...  so this is all based on info I have available today... please correct all errors I make that conflict with reality!!!

Anyway, what happens if this "autoload" feature is activated, is it will perform the "&" command on the first disk file (filename "*").  The "&" command can be summarized as executing a special file.

The special file will have the following properties in each sector:

A. start address in C1540 device (low byte, high byte)
B. data byte count
C. data
D. checksum (ADC all bytes, with carry).

If the checksum is wrong for any sector, then device will generate error "50, RECORD NOT PRESENT, TT, SS".  If no file is found (or file is REL) then you get "39, SYNTAX ERROR, TT, SS"

Please remember this special feature will only activate if both /CLK and /DATA are active (grounded to zero volts) when the C1540 powers on... and once the device recognizes this special condition, it will wait for either /DATA or /CLK (or both) to become inactive (+5 volts) before it continues to load the file...

Here is the code
Quote from: 1540 ROM
;file loop
.8:e7d8   A9 00      LDA #$00 ;reset
.8:e7da   85 87      STA $87 ;checksum
.8:e7dc   20 39 E8   JSR $E839 ;get file data
.8:e7df   85 88      STA $88 ;save SA low
.8:e7e1   20 4B E8   JSR $E84B ;update checksum
.8:e7e4   20 39 E8   JSR $E839 ;get file data
.8:e7e7   85 89      STA $89 ;save SA high
.8:e7e9   20 4B E8   JSR $E84B ;update checksum
.8:e7ec   A5 86      LDA $86 ;test "first block"
.8:e7ee   F0 0A      BEQ $E7FA ;no, continue
.8:e7f0   A5 88      LDA $88 ;Start Address low
.8:e7f2   48         PHA
.8:e7f3   A5 89      LDA $89 ;Start Address high
.8:e7f5   48         PHA
.8:e7f6   A9 00      LDA #$00 ;flag "NOT first block"
.8:e7f8   85 86      STA $86
.8:e7fa   20 39 E8   JSR $E839 ;get file data
.8:e7fd   85 8A      STA $8A ;data length
.8:e7ff   20 4B E8   JSR $E84B ;update checksum
;loop over sector data
.8:e802   20 39 E8   JSR $E839 ;get file data
.8:e805   A0 00      LDY #$00
.8:e807   91 88      STA ($88),Y ;store data
.8:e809   20 4B E8   JSR $E84B ;update checksum
.8:e80c   A5 88      LDA $88 ;address low
.8:e80e   18         CLC
.8:e80f   69 01      ADC #$01
.8:e811   85 88      STA $88 ;new address low
.8:e813   90 02      BCC $E817
.8:e815   E6 89      INC $89 ;new address high
.8:e817   C6 8A      DEC $8A ;count data bytes
.8:e819   D0 E7      BNE $E802 ;more data, loop

.8:e81b   20 35 CA   JSR $CA35 ;get file data (checksum)
.8:e81e   A5 85      LDA $85 ;get data (again)
.8:e820   C5 87      CMP $87 ;test checksum
.8:e822   F0 08      BEQ $E82C ;okay
;checksum error
.8:e824   20 3E DE   JSR $DE3E
.8:e827   A9 50      LDA #$50 ;record not present
.8:e829   20 45 E6   JSR $E645 ;generate error message

.8:e82c   A5 F8      LDA $F8 ;file end?
.8:e82e   D0 A8      BNE $E7D8 ;no, loop

;file loaded okay, execute...
.8:e830   68         PLA ;get SA low
.8:e831   85 89      STA $89
.8:e833   68         PLA ;get SA high
.8:e834   85 88      STA $88
.8:e836   6C 88 00   JMP ($0088) ;execute code

Quote from: carlssonIt seems I am referring to this Denial thread in which it says a VIC-20 with +8K expansion memory or more will search for an USR file, load it to the 1540 RAM and execute it. This feature was removed on the 1541, so supposedly the commands the computer sends out are just intercepted by a 1541. It is true there doesn't seem to be any mechanical differences between the two, but then again perhaps a 1540 ROM only works in a long board 1541?

The "&" command requires a USR file.  The "autoload" feature will accept any filetype except "REL".  The "&" command does work on 1540, 1541, 1571, and probably 1570 and 1581 (I don't have the last two devices).  I don't know how 1540 ROM would work on a 1541 board, long or short... I think it would work okay but with VIC timing instead of C64/128 timing...

According to the link above by carlsson, the C1581 is very picky!  It must have name "COPYRIGHT CBM 86".
I'm kupo for kupo nuts!