; --> VIC-20 DISK TURBO <-- ; ; (c) 2000 Pasi Ojala (Albert of Pu-239) ; ; Based on a loader written by Marko Mäkelä. Adapted 2006 to run ; standalone from ROM by Anders Carlsson (Zapac) ; ; USAGE: ; ; SYS 40963 (or START+3) to initialize turbo. Defaults to device 8. ; Change device by POKE 186 before initializing it. ; ; SYS 40960,"FILENAME" to load program. Filename may contain wildstar ; but all files are loaded to their original address (,8,1). ; ; If regular disk commands (LOAD etc) are used, the turbo needs to ; be re-initialized by SYS 40963 before using it. ; ; Theoretically, the initialize routine could change system pointers ; to LOAD command, but it might need a bit of rewriting. ; ; The file name will be stored as a string on MEMTOP #processor 6502 LEDFLASH = 0 ; LED flashing level: ; 0 = normal (LED constantly on while loading a file) ; 1 = LED glows on and off while waiting for a command ; 2 = LED on only while reading sectors ; 3 = 1 + 2 ; ========================================================================= ; The asynchronous 1540/1541/1570/1571 fast loader, computer's part ; ========================================================================= org $a000 ; ========================================================================= ; Initializations and the disk drive's part of the fastloader. ; ========================================================================= ; KERNAL definitions secnd = $ff93 ; send secondary address for LISTEN ciout = $ffa8 ; write serial data unlsn = $ffae ; send UNLISTEN command listn = $ffb1 ; send LISTEN command fa = $ba ; Current Device Number AMOUNT = $20 ; amount of data bytes to transfer with one M-W command ESCBYTE = $ef ; the escape char used in the transfers RETRIES = 20 ; amount of retries in reading a block DEFAULT_DEVICE = 8 ; Default device number ; I/O constants and the variables iecport1 = $912c ;$dd00 ;$912c dato = 32 ;32 ;32 clko = 2 ;16 ;2 iecport2 = $911f ;$dd00 ;$911f atno = 128 ;8 ;128 clki = 1 ;64 ;1 dati = 2 ;128 ;2 ; $f7-$fa is RS232 pointers, $fb-$fe is unused iec0d1a = $f7 iec0d1b = $f8 iec1d1a = $f9 iec1d1b = $fa adreslo = $fb ; first used to transfer file name, then adreshi = $fc ; used as a pointer to loaded program fnamlen = $fd store = $fe mwcmd = $0334 ; the initialization code init: jmp loader ; SYS 40960,"FILENAME" to load lda #drvcode sta adreshi ldx #lmwcmd - 1 cpmwcmd: lda mworg,x sta mwcmd,x dex bpl cpmwcmd ; send the m-w command to write the data mwloop$: jsr inidev$ ldy #lmwcmd - 1 smwcmd$: lda mwcmd,y jsr ciwait dey bpl smwcmd$ ; send the actual data bytes ldy #0 mwbyte$: lda (adreslo),y jsr ciwait iny cpy #AMOUNT bne mwbyte$ ; complete the command jsr unlsn jsr serialwait ; update the addresses clc lda #AMOUNT adc adreslo sta adreslo bcc noupdhi1$ clc inc adreshi noupdhi1$: lda #AMOUNT adc mwcmd + 2 sta mwcmd + 2 tax lda #0 adc mwcmd + 1 sta mwcmd + 1 cpx #edrvcode bcc mwloop$ jsr inidev$ lda #"U" jsr ciwait lda #"3" jsr ciwait lda #installtxt jsr $cb1e jsr unlsn jmp serialwait ; subroutine: make the current drive listen inidev$: lda fa ; get the device number bne nodef$ ; if not set, then use the default device number lda #DEFAULT_DEVICE nodef$: sta fa ; save the device number jsr listn jsr serialwait lda #$6f jsr secnd jmp serialwait ; the m-w command backwards mworg: dc.b AMOUNT,>drive,