;   The Whiz-zards Association 1988
;          FCOPY III source
;      changed for 256K system
;             by Merlin.

tel      = 7
topo     = 8
gepo     = 9
ca6      = $a6
ca7      = $a7
caa      = $aa
cab      = $ab
led0c    = $ed0c
ledb9    = $edb9
leddd    = $eddd
ledfe    = $edfe

coff     = $5000

         *= $3800

start    lda #$37
         sta 1
         lda #0
         sta $d020
         sta $d021
         lda #0
         sta $90
         lda #8
         jsr $ffb1
         lda #$6f
         jsr $ff93
         ldx $90
         jsr $ffae
         lda #9
         jsr $ffb1
         lda #$6f
         jsr $ff93
         ldy $90
         jsr $ffae
         txa
         bmi nodr8
         tya
        ; bmi nodr9
         jmp l4070
nodr8    ldx #<tex8
         ldy #>tex8
         jsr cns
sis      jsr $ffe4
         beq sis
         jmp start

nodr9    ldx #<tex9
         ldy #>tex9
         jsr cns
sus      jsr $ffe4
         beq sus
         lda #0
         sta $90
         lda #8
         jsr $ffb1
         lda #$6f
         jsr $ff93
         ldx $90
         jsr $ffae
         txa
         bmi start
         lda #8
         jsr $ffb1
         lda #$6f
         jsr $ff93
         ldy #0
wkw      lda stg,y
         jsr $ffa8
         iny
         cpy #8
         jsr $ffae
         ldx #<tex9a
         ldy #>tex9a
         jsr cns
         lda #0
         sta $c6
dtd      jsr $ffe4
         beq dtd
         jmp start

cns      stx 3
         sty 4
         ldy #0
fcr      lda (3),y
         beq aki
ejj      jsr $ffd2
         iny
         bne fcr
         inc 4
         bne fcr
aki      rts

stg      .text "m-w"
         .word $77
         .byte $02,$29,$49

tex8     .text "Please turn on "
         .text "both drives."
         .byte 0

tex9     .text "Turn off the "
         .text "Source drive, turn on"
         .byte 13
         .text "the Destination."
         .byte 0

tex9a    .byte 13,13,13
         .text "Now turn on the "
         .text "Source as well..."
         .byte 0

l4070    ldx #0
         stx $d011
l4075    stx gfg
         lda #2
         cpx #0
         beq xins
         lda #8
xins     sta ggg
         lda #$00
         ldy #$49
         sta ca6
         sty ca7
         lda #$00
         ldy #$07
         sta caa
         sty cab
l4085    jsr l401d
         ldy #$02
l408a    lda l4100,y
         jsr leddd
         dey
         bpl l408a
         lda caa
         jsr leddd
         lda cab
         jsr leddd
         lda #$22
         jsr leddd
         ldy #$00
         tax
l40a5    lda (ca6),y
         jsr leddd
         inc ca6
         bne l40b0
         inc ca7
l40b0    inc caa
         bne l40b6
         inc cab
l40b6    dex
         bne l40a5
         jsr ledfe
         lda caa
         cmp #d777-d0700
         bcc l4085
         ldx gfg
         inx
       ;  cpx #2
         bcc l4075
       ;  dec gfg
l40c0    jsr l401d
         ldy #$04
l40c7    lda l4104,y
         jsr leddd
         dey
         bpl l40c7
         jsr ledfe
         inc gfg
         lda gfg
         cmp #2
        ; bcc l40c0
         sei
         lda $dd00
         and #$c7
         sta $dd00
         lda $dd00
l40cf    lda $dd00
         and #$80
         bne l40cf
         bit $dd0d
         lda $dd01
         ldx #0
l40d0    stx fyf
         lda $dd00
         and #$c7
         cpx #0
         beq vyhv
         ora #$20
vyhv     sta $dd00
         lda $dd00
         sta $0800
         lda #$00
         ldy #$42
         sta ca6
         sty ca7
         ldx #$07
         ldy #$00
         sty caa
l40e2    ldy caa
         lda (ca6),y
         sty caa
         jsr l4000
         inc caa
         bne l40e2
         inc ca7
         dex
         bne l40e2
         ldx fyf
         inx
         cpx #2
         ;bcc l40d0
cvbe     lda #$1b
         sta $d011
         jmp l6000

l4000    ldy #$ff
         sty $dd03
         sta $dd01
cgcg     lda $dd0d
         and #$10
         beq cgcg
         rts

l401d    lda #$08
         ora gfg
         jsr led0c
         lda #$6f
         jmp ledb9

l4100    .byte $57,$2d,$4d

l4104    .byte >d07st,<d07st,$45,$2d,$4d

llo      = 2
lhi      = 3
klo      = 4
khi      = 5
lfr      = 6
getbn    = 7
hfhr     = 8
ltab     = 9

l6000    sei
         lda #$3c
         sta $dd02
         lda #$80
         sta $dd07
         ldx #$2e
         lda #0
l6019    sta $d000,x
         dex
         bpl l6019
         lda #$7f
         sta $dc0d
         lda $dc0d
         lda #$27
         sta $d018
         lda #$c8
         sta $d016
         lda #$0f
         sta $d021
         lda #$00
         sta $d020
         ldx #$00
l6042    sta $d800,x
         sta $d900,x
         sta $da00,x
         sta $dae8,x
         inx
         bne l6042
         ldx #$18
l6063    lda l5f80,x
         sta $d400,x
         dex
         bpl l6063
         ldy #1
         sty 5
         dey
         sty 2
         sty 4
         lda #>coff+$0100
         sta 3
jsjs     lda (2),y
         sta (4),y
         iny
         bne jsjs
         inc 3
         inc 5
         lda 5
         cmp #$10
         bcc jsjs
sjsk     lda coff,y
         sta 0,y
         lda l6100,y
         sta l1237,y
         iny
         bne sjsk
         lda #$1b
         sta $d011
         jmp l0d7b

dd676    = $d676
df24b    = $f24b
df40b    = $f40b
df41e    = $f41e
df497    = $f497
df4f0    = $f4f0
df505    = $f505
df50a    = $f50a
df556    = $f556
df6c5    = $f6c5
df8ec    = $f8ec
df934    = $f934
df940    = $f940
df969    = $f969
dfda3    = $fda3
dfe00    = $fe00
dfe0e    = $fe0e
dfedb    = $fedb

         *= $00
         .offs $4200

d00      .byte $01,$01,$01,$01,$01
         .byte $00
d06      .byte $01,$00
d08      .byte $06
d09      .byte $01
d0a      .byte $06
d0b      .byte $0e
d0c      .byte $02
d0d      .byte $06
d0e      .byte $00
d0f      .byte $0d
d10      .byte $00,$00
d12      .byte $00
d13      .byte $07
d14      .byte $01
d15      .byte $04
d16      .byte $ee
d17      .byte $0d
d18      .byte $00
d19      .byte $00
d1a      .byte $00
d1b      .byte $00,$00
d1d      .byte $01,$00,$00
d20      .byte $30
d21      .byte $00
d22      .byte $01
d23      .byte $00
d24      .byte $52
d25      .byte $65,$25,$29,$52,$54
         .byte $e5,$35
d2c      .byte $29,$4a
d2e      .byte $00
d2f      .byte $04
d30      .byte $00
d31      .byte $03,$06,$00
d34      .byte $0a
d35      .byte $00
d36      .byte $ff
d37      .byte $00,$07,$08,$7b
d3b      .byte $00
d3c      .byte $00,$00,$00,$00,$06
         .byte $00,$01
d43      .byte $15,$60,$60
d46      .byte $00,$07,$fe,$18,$00
         .byte $02,$04,$00
d4e      .byte $01,$ba,$00
d51      .byte $07,$03,$23,$00,$00
         .byte $0a,$13,$12
         .byte $13,$0a,$0a,$0a,$0a
         .byte $02,$12,$00
         .byte $00,$05,$fa,$05

d65      dex
         bne d9a
         lda #$f2
         inx
         stx d35
         ldx d19
         sta d06a5,x
         jmp d01cc

d75      lda #$c0
         sta d2c
         bne d7b
d7b      sta d00
         cli
d7e      lda d00
         bmi d7e
d82      bit d20
         bvs d82
         bmi d82
         sei
         rts

d8a      stx d19
         txa
         eor d18
         eor d17
         eor d16
         sta d1a
         jsr df934 ; gcr header
         ldx #$5a
d9a      jsr df556 ; find sync
d9d      bvc d9d
         clv
         lda $1c01
         cmp d24,y
         bne d65
         iny
         cpy #$08
         bne d9d
         jsr df556
         lda #$06
         sta d31
         ldy #$ba
db6      bvc db6
         clv
         lda $1c01
         sta (d30),y
         iny
         bne db6
dc1      bvc dc1
         clv
         lda $1c01
         sta d0700,y
         iny
         bne dc1
         sty d23
         ldy #$bd
dd1      ldx #$05
dd3      lda (d30),y
         cmp d02ee-1,x
         bne def
         iny
         cpy d23
         beq de4
ddf      dex
         bne dd3
         beq dd1
de4      tya
         bne df1
         inc d31
         lda #$fb
         sta d23
         bne ddf
def      ldx #$00
df1      stx d37
         jmp d0168

df6      lda #$08
         jsr d02ca
         lda d09
         cmp #$4c
         beq d010a
         cmp #$46
         bne d0116
         jsr dfda3
         beq d010d
d010a    jsr dfe0e
d010d    jsr dfe00
         jsr d02ca
         jmp df505

d0116    lda #$07
         sta d31
         sta d2f
         lda d12
         ldx d13
         sta d16
         stx d17
         eor d18
         eor d17
         sta d09
         lda #$00
         sta d0a
         sta d34
         sta d19
d0132    eor d09
         sta d1a
         jsr df940
         inc d19
         lda d19
         cmp d43
         bcc d0132
         jmp d0550

d0144    lda #$ff
d0146    bvc d0146
         clv
         sta $1c01
         dex
         bne d0146
         rts

         *= $0168
dstc     = *-$0101

d0168    ldy d3c
         bmi d0188
         lda #$ff
         sta d3c
         jsr getcb ;$f1(ok),5=c,$f4
         tax
         jsr d02b6
         txa
         bmi d0181
         ldx d06a5,y
         beq d0181
         ora #$f0
d0181    sta d06a5,y
         bmi d0188
         inc d0a
d0188    lda d0a   ; te c. se's
         bne d018f
         jmp df505
d018f    ldy d37
         bmi d01cc
         lda d19   ; gelezen se.
         sta d3c
         jsr putcb
         stx d37
         tya
         jsr putcb2 ; 0=+,2=-
         ldy #$ba
         ldx d06ba
         bne d01af
d01a7    ldx d0600,y
d01aa    bit $180d
         beq d01aa
d01af    stx $1801
         bit $1800
         iny
         bne d01a7
d01b8    ldx d0700,y
d01bb    bit $180d
         beq d01bb
         stx $1801
         bit $1800
         iny
         bne d01b8
         jsr d02b6
d01cc    lda $1c00
         eor #$08
         sta $1c00
         ldx d19
         dec d0a
         bne d01dd
         jmp d0168  ; tr. ready
d01dd    txa
         clc
         adc d35    ;????

d01e1    cmp d43    ; maxse
         bcc d01e7
         sbc d43
d01e7    tax        ; next se
d01e8    cpx d3c    ; last se
         beq d01f1
         lda d06a5,x ; sector done?
         bpl d01f5
d01f1    inx         ; yes
         txa
         bpl d01e1
d01f5    lda #$03    ; no
         sta d35
         jmp d8a

d01fc    ldx #$ff
         stx d3c
         stx d37
         inx
         lda d0e
         bne d01e8
         lda d43 ; tot no.se's
         sta d23
d020b    lda #$5a
         sta d46   ; sync present ??
d020f    ldy #$ff
         sty $1805
         ldx #$64
d0216    lda $1c00
         bpl d0225
         lda $1805
         bne d0216
         lda #$06  ; no (L?-error)
         jmp df969

d0225    lda $1c01
         clv
d0229    bvs d0234
         dey
         bne d0229
         dex
         bne d0229
         jmp df6c5 ; no data .

d0234    clv
         ldy $1c01
         cpy #$52  ; header
         beq d0243
         dec d46
         bne d020f
d0240    jmp df40b ; bad header.(H)

d0243    ldx #$00
d0245    bvc d0245
         clv
         lda $1c01
         sta d25,x
         inx
         cpx #$07
         bcc d0245
         stx d0c
         jsr df497
         ldx d19
         txa
         eor d16
         eor d17
         eor d18
         eor d1a
         beq d026b
         dec d23
         bne d020b
         jmp df41e ; h. checksum (I)

d026b    lda d06   ; tr
         cmp d18   ; he. tr
         bne d0240
         lda d0b   ; get ID?
         bne d027d
         lda d16   ; yes
         sta d12
         lda d17
         sta d13
d027d    inx       ; sector+1
         stx d0b
         txa
         jmp d01e1

d0284    lda #$ff
         jsr putcb
         lda d06
         sta d18   ; track
         jsr putcb2
         lda $1801
         jsr getcb
         bne getcb2
         jmp d0346 ; r/s gedrukt.

getcb    lda #$00
         sta $1803
getcb2   lda #$10
d02a2    bit $180d
         beq d02a2
         lda $1800
         lda $1801
         rts

putcb    ldx #$ff
         stx $1803
putcb2   sta $1801
d02b6    lda #$10
d02b8    bit $180d
         beq d02b8
         lda $1800
         rts

d02c1    lda #$00
         sta d1d
         sta d0e
         rts

d02d7    lda d0e
         sec
         sbc dfedb,y
         sta d0e
         lda dfedb,y
         inc d1d
         bne d02e8
d02e6    lda d0e
d02e8    cli
         jsr dd676
         sei
         rts

d02ee    .byte $b5,$d4
         .byte $52
         .byte $4b
         .byte $2d

acton    lda #0
         sta $1803
         lda #$10
adad     bit $180d
         beq adad
actoff   lda $1800
         and #1
         cmp #0     ;src=0,dest=1
fyf      = *-d00+$4200-1
         bne acton
         lda $1801
         rts

         *= $0300

d0300    lda d00
         and #$06
         beq d0317
         cmp #$02
         beq d0314
         cmp #$06
         beq d0311
         jmp df6
d0311    jmp df505
d0314    jmp d01fc
d0317    ldx #$07
         stx d31
         dex
         stx d4e
         jsr df50a
d0321    bvc d0321
         clv
         lda $1c01
         sta (d30),y
         iny
         bne d0321
         ldy #$ba
d032e    bvc d032e
         clv
         lda $1c01
         sta d0600,y
         iny
         bne d032e
         sty d36
         sty d34
         sty d2e
         jsr df8ec
         jmp df4f0

d02c8    lda #$00
d02ca    sta d21
         lda $1c00
         and #$f7
         ora d21
         sta $1c00
         rts

d0346    ldx #dstc
         txs
         jsr d02c1
         sta d2c
         lda #$04
         jsr d02ca
         jsr acton
         sta d3b ; tries
         jsr getcb2
         sta d10 ; track to go to
         jsr getcb2
         beq d0364
d0360    lda #$f1
d0364    sta d08   ;All=0,Used=$f1
         jsr getcb2
         beq d0366
         bmi d03ce
         sta d1b
         lda d10
         sta d14
         jmp d04c0
d0366    lda #$08
         jsr d02ca
         lda d08
         sta d0b
         beq d03ca
         lda #$12
         sta d06
d0375    ldx #$03
d0377    lda #$b0
         jsr d7b
         lda #$e0
         jsr d7b
         cmp #$01
         beq d03a6
         lda d2c
         bne d038e
         jsr d75
         bpl d0377
d038e    dex
         bne d0377
         ldy d1d
         lda dfedb,y
         bne d03a0
         jsr d02e6
         ldx #$81
         jmp d04f8
d03a0    jsr d02d7
         jmp d0375

d03a6    jsr d02e6
         ldx #$05
         ldy #$00
d03ad    txa
         and #$03
         beq d03b9
         lda d0700,x
         sta d0639,y
         iny
d03b9    inx
         cpx #$91
         bcc d03ad
         lda #$00
         sta d066c
         sta d066d
         sta d066e
d03ca    lda d10   ; tr. to go to
         sta d06
d03ce    jsr d02c8
         lda #$80
         jsr putcb ; eerste byte.
         lda d06
         sta d14
d03da    jsr df24b
         sta d43   ; no. of sects
         lda d06
         asl a
         adc d06
         tax       ; x=tr*3
         ldy #$00
         sty d0a
d03e9    lda #$08
         sta d23
d03ed    lsr d0639-3,x
         bcs d03f5
         lda #$00
         .byte $2c
d03f5    lda d08
         sta d06a5,y ;bij all b.alles 0
         and #$80
         bne d0400
         inc d0a   ; by all b.no. secs
d0400    iny
         cpy d43
         bcs d040c
         dec d23
         bne d03ed
         inx
         bne d03e9
d040c    lda d0a   ; te copyen se's
         bne d0413
         jmp d04b5 ; klaar met tr.
d0413    jsr d0284 ; r/s en haal hi adr
         clc
         adc d0a   ; st.adr+te c.se's
         jsr d02b6
         bcc d0423
d0420    ldx #$88  ; geh. adr overflow
         jmp d04f2
d0423    jsr d02c1  ;d1d=0,d0e=0
         sta d0c    ;=0
d0428    sta d19
         lda d3b
         sta d0f
d042e    ldx #$03
d0430    lda #$e2
         jsr d7b
         ldy d3c
         bmi d0442
         jsr getcb
         sta d06a5,y
         jsr d02b6
d0442    lda d00
         cmp #$03
         bne d044b
         dex
         bne d0430
d044b    cmp #$01
         beq d0458
         ldx d19
         sta d06a5,x
         lda d0c
         beq d0490
d0458    ldy d1d
         lda dfedb,y
         beq d048d
         ldx #$00
         stx d0a
         ldx d43
d0465    lda d06a4,x
         cmp #$f1
         beq d0473
         inc d0a
         lda #$00
         sta d06a4,x
d0473    dex
         bne d0465
         lda d0a
         beq d048d
         dec d0f
         bne d042e
         lda d2c
         beq d0488
         jsr d02d7
d0485    jmp d0428

d0488    jsr d75
         bpl d0485
d048d    jsr d02e6
d0490    ldy #0
d04a0    lda d06a5,y
         ora #$f0
         cmp #$f1
         beq d04b0
         jsr putcb
         tya
         jsr putcb2
d04b0    iny
         cpy d43
         bne d04a0
d04b5    inc d06
         lda d06
         cmp #$30
         bcs d04f0
         jmp d03da

d04c0    lda d14
         sta d06
         lda #$e6
         jsr d7b
d04c9    jsr d0284
         sta d09
         jsr d02b6
d04d1    lda d3b
         sta d0f
d04d5    lda #$e4
         jsr d7b
         cmp #$01
         bne d0527
d04de    lda $1800
         lda d06
         inc d06
         cmp d1b
         beq d04fd
         jmp d04c9

d04f0    ldx #$fe
d04f2    lda d06
         sta d1b
d04f6    lda #$08
d04f8    jsr d02ca
         txa
         .byte $2c
d04fd
d0500    lda #$fd
d0502    jsr putcb
         lda $1801
         jsr getcb
         tax
         bne d0511
         jmp d0346

d0511    jsr d02b6
         cpx #$01
         beq d04d1
         bne d04de

d0527    ldx d0a
         beq d0544
         lda d15
d052d    clc
         adc #$ba
         tay
         ldx #$02
d0533    jsr getcb2
         iny
         bne d0533
         dex
         bne d0533
         txa
         dec d0a
         bne d052d
d0541    inx
         bpl d0541
d0544    lda $1800
         lda #$fb
         dec d0f
         beq d0502
         jmp d04d5

d0550    lda #$01
         sta d46
         lda #$00
         sta d0d
         jsr putcb
         inc $1803
         jsr d0628
d0561    lda #$55
         jsr d0146
         ldx #$06
         jsr d0144
d056b    bvc d056b
         clv
         lda $1801
         sta $1c01
         ldx #$09
         ldy d46
d0578    bvc d0578
         clv
         lda (d30),y
         sta $1c01
         iny
         dex
         bne d0578
         lda #$55
         ldx #$09
         jsr d0146
         ldx #$05
         jsr d0144
         dex
         ldy #$bb
d0593    bvc d0593
         clv
         lda $1801
         sta $1c01
         iny
         bne d0593
         inx
         beq d0593
         ldx d51
         lda d46
         clc
         adc #$0a
         sta d46
         dec d19
         bne d0561
d05af    bvc d05af
         jsr dfe00
         lda $1800
         jsr d02c8
         lda d43
         sta d0a
         lda #$00
         sta d46
         sta d15
         jsr putcb
         inc $1803
d05ca    jsr df556
         ldy d46
         ldx #$09
d05d1    bvc d05d1
         clv
         lda $1c01
         sta d09
d05d9    bvc d05d9
         clv
         iny
         lda $1c01
         eor d0700,y
         beq d05e7
         sta d0d
d05e7    dex
         bne d05d9
         inc d15
         lda $1801
         eor d09
         bne d0621
         iny
         sty d46
         jsr df556
         sty d15
         dey
         ldx #$bc
d05fe    bvc d05fe
d0600    clv
         lda $1801
         eor $1c01
         bne d0624
d0609    inx
         bne d05fe
         iny
         beq d05fe
d060f    bvc d060f
         lda $1801
         dec d0a
         lda d0d
         bne d0621
         lda d0a
         bne d05ca
         jmp df505
d0621    jmp df6c5

d0624    sta d0d
         bne d0609
d0628    lda $1c0c
         and #$1f
         ora #$c0
         sta $1c0c
         lda #$ff
         sta $1c03
         rts

         *= $0638
d0638    .byte $00
d0639    .byte $00,$00,$00,$00,$00
         .byte $00,$00,$00
         .byte $00,$00,$00,$00,$00
         .byte $00,$00,$00
         .byte $00,$00,$00,$00,$00
         .byte $00,$00,$00
         .byte $00,$00,$00,$00,$00
         .byte $00,$00,$00
         .byte $00,$00,$00,$00,$00
         .byte $00,$00,$00
         .byte $00,$00,$00,$06,$06
         .byte $06,$06,$06
         .byte $06,$06,$06
d066c    .byte $06
d066d    .byte $06
d066e    .byte $06,$06,$06,$06,$06
         .byte $06,$06,$06
         .byte $06,$06,$06,$06,$06
         .byte $06,$06,$06
         .byte $06,$06,$06,$06,$06
         .byte $06,$06,$06
         .byte $06,$06,$06,$06,$06
         .byte $06,$06,$06
         .byte $06,$06,$06,$06,$06
         .byte $06,$06,$06
         .byte $06,$06,$06,$06,$06
         .byte $06,$06,$06
         .byte $06,$06,$06,$06,$06
         .byte $06
d06a4    .byte $06
d06a5    .byte $06,$06,$06,$06,$06
         .byte $06,$06,$06
         .byte $06,$06,$06,$06,$06
         .byte $06,$06,$06
         .byte $06,$06,$06,$06,$06
d06ba    .byte $06,$06,$06,$06,$06
         .byte $06,$06,$06
         .byte $06,$06,$06,$06,$06
         .byte $06,$06,$06
         .byte $06,$06,$06,$06,$06
         .byte $06,$06,$06
         .byte $06,$06,$06,$06,$06
         .byte $06,$06,$06
         .byte $06,$06,$06,$06,$06
         .byte $06,$06,$06
         .byte $06,$06,$06,$06,$06
         .byte $06,$06,$06
         .byte $06,$06,$06,$06,$06
         .byte $06,$06,$06
         .byte $06,$06,$06,$06,$06
         .byte $06,$06,$06
         .byte $06,$06,$06,$06,$06
         .byte $06

         *= $0700

d0700    dec d0d
         bne d07en
         ldx $49
         lda #<d0708
         sta $0107,x
         lda #>d0708
         sta $0108,x
         jmp $f505
d07en    jmp $f99c

d07st    lda #0
         sta $1803
         sta d0f
         lda #1
         sta d0e
         lda #$80
         sta d0d
         lda #$e0
         sta 4
         rts

d0708    lda #0
         sta $1800
         sta $1803
         ldx #5
         ldy #$b0
d0704    lda #1
         sta d0e
         sty 4
d070a    lda 4
         bmi d070a
         cmp #1
         bne d070b
         cmp d22
         beq d0710
d070b    dex
         bne d0704
         ldy #$c0
         bne d0704

d0710    sei
         ldx #0
         stx $1803
         lda #$0b
         sta $180c
         lda #$e0
         sta $1807
         lda #$ff
         sta $1806
         bit $180d
         lda #2
ggg      = *-d00+$4200-1
         sta $1800
         lda #$10
dudnd    bit $180d
         beq dudnd
         lda #0
         sta $1800
d0717    lda #$10
d0719    bit $180d
         beq d0719
d0723    lda $1800
         sta $07ff
         jmp $eb22
         and #1
         cmp #0     ;src=0,dest=1
gfg      = *-d00+$4200-1
         bne d0717
         lda $1801
         .byte $9d,0,0
d072d    = *-1
         inx
         bne d0717
         inc d072d
         lda d072d
         cmp #$07
         bne d0717
         jmp d0346
d777

; The Whiz-zards Association 1988

         *= $00
         .offs coff

l00      .byte $df
l01      .byte $dd,$42
te1      .byte $01,$04,$20
         .byte $42,$41,$4d
         .byte $2d,$50,$12,$05,$13
         .byte $13,$20,$53
         .byte $54,$4f,$50,$00
te2      .byte $43,$0f,$10,$19,$20
         .byte $44,$09,$13,$0b,$00
te3      .byte $44,$09,$12,$20,$53
         .byte $0f,$15,$12,$03,$05,$00
te4      .byte $45,$0e,$04,$20,$0f
         .byte $06,$20,$43
         .byte $0f,$10,$19,$00
te5      .byte $49,$0e,$13,$05
         .byte $12,$14,$20,$53,$0f
         .byte $15,$12,$03,$05,$00
te6      .byte $55,$13,$05,$12
         .byte $20,$42,$12,$05
         .byte $01,$0b,$00
te8      .byte $49,$0e,$13,$05,$12
         .byte $14,$20,$44,$05,$13
         .byte $14,$09,$0e,$01,$14
         .byte $09,$0f,$0e,$00
te9      .byte $42,$01,$04,$20
         .byte $54,$12,$01
         .byte $03,$0b,$00
te11     .byte $44,$09,$12,$20
         .byte $44,$05,$13,$14
         .byte $09,$0e,$01,$14
         .byte $09,$0f,$0e,$00
te12     .byte $d5,$93,$85,$84,$00
te13     .byte $a0,$c1,$8c,$8c,$00
te14     .byte $d9,$85,$93,$00
te15     .byte $ce,$8f,$a0

l9d      .byte $00
l9e      .byte $a9
l9f      .byte $ea
la0      .byte $00 ; all bl.
la1      .byte $79
la2      .byte $00
la3      .byte $f4
la4      .byte $00
tobn
la5      .byte $00
frbn
last
la6      .byte $10
la7      .byte $02
la8      .byte $00
la9      .byte $04
laa      .byte $bf
lab      .byte $a9
lac      .byte $01
lad      .byte $00
lae      .byte $00
laf      .byte $b1  ;,$0
lb1      .byte $40
lb2      .byte $20
lb3      .byte $40
lb4      .byte $00
lb5      .byte $00
lb6      .byte $00
lb7      .byte $10
lb8      .byte $01
lb9      .byte $01
lba      .byte $00 ; repair no
lbb      .byte $e2
lbc      .byte $00
lbd      .byte $00
lbe      .byte $a0
lbf      .byte $01
lc0      .byte $20
lc1      .byte $f6
lc2      .byte $e0
lc3      .byte $00,$00,$00,$00,$00
         .byte $00,$00,$00,$00
         .byte $00,$00,$00,$00
         .byte $00,$00,$00,$00
         .byte $00,$00,$00,$00
ld9      .byte $00
llda     .byte $00
ldb      .byte $00
ldc      .byte $00
begtr    .byte 1
endtr    .byte 36

lfc      ldx #$00     ; 1500 t/m 157f=0
                      ; x=sector
lfe      lda l152a,x
         beq l0118
         ldy lab
         sta l1067,y
         lda l1500,x
         sta l0f7f,y
         lda l1515,x
         sta l114f,y
         inc lab
         bne l0126
l0118    lda l1554,x
         beq l0126
         lda l153f,x
         ldy lac
         sta (la1),y
         dec lac
l0126    inx
         cpx #$15    ; max.sects+1
         bcc lfe
l0135    rts

l0136    ldx #te1
         jsr l0c06
         lda #$7f
         sta $dc00
l0140    cmp $dc01
         bne l0140
l0145    ldx #te6
         bne l0156
l0149    ldx #te4
l0156    jsr l0c1c
l0159    jsr waitfd
         and #$00
         jsr putdb
         jmp l0d7b

         *= *+10
cstack   = *-$0101

l0186    ldx #te5
         jsr l0c06
         lda #$7f
         sta $dc00
         ldx #$ef
l0192    cmp $dc01
         beq l019c
         cpx $dc01
         bne l0192
l019c    jsr l0bf8  ; clear comndline
l01a0    lda #$18
         sta la3  ; $18=c,d
         sta la4
         ldx #$00
         stx lab
         stx la1
         dex
         stx la2
         stx lac
         lda la0
         beq l01b9
         lda #$01
l01b9    sta lb9  ;all=0,used=1

l01bb    lda #$00
         tax
l01be    sta l1500,x
         inx
         bpl l01be
l01c4    jsr getdb
         bpl l01cc
         jmp l0446

l01cc    sta lae  ; gelezen sector
         tay
         jsr getdb2 ;0=+,2=-
         sta la7
         lda l152a,y ; al gelezen?
         beq l01df   ; neu
         ldy #$00    ; joa, dan geen
         sty la7     ; extra geh. nodig
         beq l01e8
l01df    inc la3    ; hi teller
         lda la3
         sta l152a,y ; waar staat se?
         ldy #$00
l01e8    sta l9e    ; hi van se.
         sta l03a8
l01ed    lda $dd0d
         beq l01ed
         lda $dd01
         sta l1400,y
         iny
         bne l01ed
         ldy #$ba
l01fd    lda $dd0d
         beq l01fd
         lda $dd01
         sta l1300,y
         iny
         bne l01fd
         dec l01
         ldy #$00
         sty lb4
         ldx #$00
         beq l021a
l0215    jmp l02c1

l0218    ldx laf
l021a    lda l1400,x
         inx
         beq l0215
         sta lc2
         lsr a
         lsr a
         lsr a
         tay
         lda l0f4f,y
         sta la6
         lda l1400,x
         asl a
         rol lc2
         asl a
         rol lc2
         lda l1400,x
         lsr a
         and #$1f
         tay
         lda l0f4f,y
         sta la9
         inx
         lda l1400,x
         ror a
         lsr a
         lsr a
         lsr a
         tay
         lda l0f2f,y
         ora la9
         sta lc1
         inx
         lda l1400,x
         asl a
         rol l13ff,x
         lsr a
         lsr a
         lsr a
         tay
         lda l0f2f,y
         sta laa
         inx
         lda l1400,x
         sta la5
         and #$1f
         tay
         lda l0f2f,y
         sta l9f
         lda l13ff,x
         asl la5
         rol a
         asl la5
         rol a
         asl la5
         rol a
         and #$1f
         tay
         lda l0f4f,y
         sta ld9
         stx laf
         lda lc2
         and #$1f
         tay
         lda l0f2f,y
         ora la6
         ldy lb4
         beq l02b7
         sta (l9d),y
         iny
l0296    lda lc1
         sta (l9d),y
         iny
         lda l13fe,x
         and #$1f
         tax
         lda l0f4f,x
         ora laa
         sta (l9d),y
         iny
         lda ld9
         ora l9f
         sta (l9d),y
         iny
         sty lb4
         inc laf
         jmp l0218

l02b7    sta lbe
         beq l0296

l02bb    ldx laf
         lda l13ba,x
         inx
l02c1    sta lc2
         lsr a
         lsr a
         lsr a
         tay
         lda l0f4f,y
         sta la6
         lda l13ba,x
         asl a
         rol lc2
         asl a
         rol lc2
         lda l13ba,x
         lsr a
         and #$1f
         tay
         lda l0f4f,y
         sta la9
         inx
         lda l13ba,x
         ror a
         lsr a
         lsr a
         lsr a
         tay
         lda l0f2f,y
         ora la9
         sta lc1
         inx
         lda l13ba,x
         asl a
         rol l13b9,x
         lsr a
         lsr a
         lsr a
         tay
         lda l0f2f,y
         sta laa
         inx
         lda l13ba,x
         sta la5
         and #$1f
         tay
         lda l0f2f,y
         sta l9f
         lda l13b9,x
         asl la5
         rol a
         asl la5
         rol a
         asl la5
         rol a
         and #$1f
         tay
         lda l0f4f,y
         sta ld9
         stx laf
         lda lc2
         and #$1f
         tay
         lda l0f2f,y
         ora la6
         ldy lb4
         sta (l9d),y
         lda lc1
         iny
         beq l0358
         sta (l9d),y
         iny
         lda l13b8,x
         and #$1f
         tax
         lda l0f4f,x
         ora laa
         sta (l9d),y
         iny
         lda ld9
         ora l9f
         sta (l9d),y
         inc laf
         iny
         sty lb4
         jmp l02bb

l0358    sta lbf
         lda la7   ; 0=+,2=-
         beq l0395
         lda lbe
         cmp #$07
         bne l0395
         ldy #$ff
         lda (l9d),y
         ldy #$01
         cmp (l9d),y
         bne l0395
         tya
         eor lbf
         dey
         cmp (l9d),y
         bne l0395
         ldx la1     ; empty se.
         bne l037c
         dec la2
l037c    dec la1
         inc lac
         ldx lae     ; se
         sta l153f,x
         dec la3     ; mem hi-1
         lda #$00
         sta l152a,x
         lda #$01
         sta lb9
         sta l1554,x
         bne l03ba
l0395    ldx lae   ; normal se
         lda lbf    ; chksum
         sta l1515,x
         lda lbe    ; data (7)
         sta l1500,x
         ldy #$00
         sty la7
         tya
l03a8    = *+2
l03a6    eor $ff00,y
         iny
         bne l03a6
         ldy #$f4
         ldx lbe
         cpx #$07
         bne l03bc ; no data(7)
         ldy #$05
         cmp lbf
         bne l03bc ; chksum err.
l03ba    ldy #$f1  ; okidoki
l03bc    inc l01
         dec $dd03
         sty $dd01
l03c4    lda $dd0d
         beq l03c4
         lda $dd01
         lda ldc    ; dir=1
         bne l03e2
         lda #$2d
         ldx la7    ; 2=-
         bne l03dd
         tya        ; error
         and #$0f
         tay
         lda l0c5a,y
l03dd    ldx lae
         jsr l0cf1
l03e2    jmp l01c4

l03e5    jsr lfc   ; insert destination
l03f1    ldx #te8
         jsr l0c06
l03fc
l0416    lda #$7f
         sta $dc00
         ldx $dc01
         cpx #$ef
         beq l042a
         cmp $dc01
         bne l03fc
         jmp l0145

hntf     jmp l0e6f ; print directory

l042a    jsr waitfd
         lda #0
         jsr putdb
         lda $dd01
         jsr l0c7c
         ldx #$ff
         stx la2
         inx
         stx la1
         stx la8
         stx la4
         stx lb9
         lda #2
         jsr setdr
         lda lb8     ; tries
         jsr putdb
         lda lbb     ; track
         jsr putdb2
         lda la0     ; all=0
         jsr putdb2
         lda lad
         jsr putdb2  ; write

l0443    jsr getdb

l0446    cmp #$80
         beq l03e2
         cmp #$ff
         beq l0450
         jmp l04bd
l0450    lda #$7f   ; check r/s
         sta $dc00
         cmp $dc01
         bne l045e
         jsr getdb2
         jmp l0145
l045e    jsr getdb2
         ldx ldc
         beq l046b
         cmp #18
         bne hntf
l046b    sta lad    ; curr.tr
         jsr l0c64
         stx lc0    ; no. of sectrs
         dec $dd03  ; output
         jsr waitfd
         txa
         jsr putdb2  ;sect (niet 0)
         ldx la4     ;$18,$19,$2d
         bne l0495
         jmp l052a
l0495    ldx ldc
         bne l049a
         lda #$ff
         ldx lad
         cpx endtr
         beq l04a0
l049a    lda lb9     ;0=all
         beq l049e
         lda #$00   ;used..
         sec
         sbc la2    ;ff
l049e    clc
         adc la3    ;$18,$19,$2d
         clc
         adc lc0
         lda #$7f
         bcc l04a0
         lda #$ff

l04a0    jsr putdb2  ; hi st.adr
         lda $dd01
         jsr lfc
         jmp l01bb

l04b3
filled   jmp l03e5 ;schrijven
l04ba    jmp l0149 ; end disk.

l04bd    cmp #$fd
         bne l04f5
l04d6    ldx lad
         inx
         cpx endtr
         stx lbb
         bcs l04ba
         jsr waitfd ; normal inst source
         lda #0
         jsr putdb
         lda $dd01
         lda #1
         jsr setdr
         lda lb8     ; tries
         jsr putdb
         lda lbb     ; track
         jsr putdb2
         lda la0     ; all=0
         jsr putdb2
         lda #$ff
         jsr putdb2  ; continue read
         lda #$04
         jsr putdb2
         lda $dd01
         jmp l0186

l04f5    cmp #$fb
         bne l04fc
         jmp l0c91  ; bad track

l04fc    cmp #$f0
         bcc l051c
         and #$0f
         tay
         jsr getdb2
         tax
         lda l1554,x
         bne l0519
         lda l152a,x
         bne l0519
         lda l0c5a,y
         sta lb9
         jsr l0cf1
l0519    jmp l01c4

l051c    cmp #$88  ; geh. overflow
         beq l04b3
l0527    jmp l0136 ; bad bam.

l052a    ldx #$00
         stx lae
         jsr l0d59
l0533    ldy lad
         lda (llda),y
         ora lba
         tay
         jsr putdb2
         lda $dd01
         cpy #$4c
         beq l0546
         cpy #$46
         bne l0549
l0546    jmp l0443

l0549    lda #<l1337
         ldx #>l1337
         sta lb5
         stx lb6
         lda #$19
         sta la3
l0555    lda lb5
         ldx lb6
         sta lb2
         stx lb3
         ldx lae
         jsr l0d59
         ldy lad
         lda (llda),y
         cmp #$2b
         beq l05b2
         cmp #$43
         beq l05b2
         cmp #$49
         beq l05b2
         tay
         lda #$ff
         sta lc3,x
         tya
         tax
         ldy #$00
         lda #$41
         cpx #$2d
         bne l058b
         lda la1
         bne l0587
         dec la2
l0587    dec la1
         lda (la1),y
l058b    pha
         iny
         jsr ldd
         pla
         eor #$01
         ldy #$03
         jsr ldd
         ldy #$00
l059a    ldx #$04
l059c    lda l05ad,x
         sta $ff00,y
         iny
         beq l05aa
         dex
         bpl l059c
         bmi l059a
l05aa    jmp l06de

l05ad    .byte $b5,$d4,$52,$4b,$2d

l05b2    lda #$0e
         sta lb4
         lda l0628
         ldx l0629
         jsr l0be8
         dec l01
         ldy la8
         lda l1067,y
         sta l9e
         sta l05eb
         bmi l05d8
         bpl l05dc
l05d8    lda la3
         inc la3   ; next hibyte
l05dc    ldx lae
         sta lc3,x
         sta ldb
         lda lba
         bpl l05f6
         ldx #$00
         txa
l05eb    = *+2
l05e9    eor $ff00,x
         inx
         bne l05e9
         sta l114f,y
         ldx #$07
         bne l05f9
l05f6    ldx l0f7f,y
l05f9    ldy #$00
         sty lb7
         lda l1237,x
         asl a
         asl a
         asl a
         sta la6
         txa
         and #$0f
         tax
         lda l0f6f,x
         lsr a
         ror lc1
         lsr a
         ror lc1
         ora la6
         sta la6
         jmp l0647
l0619    lda #$a9
         ldx #$00
         jsr l0be8
         ldx la8
         lda l114f,x
         jmp l0649

l0629    = *+1
l0628    lda (l9d),y
         tax
         lda l1237,x
         asl a
         asl a
         asl a
         sta la6
         txa
         and #$0f
         tax
         lda l0f6f,x
         lsr a
         ror lc1
         lsr a
         ror lc1
         ora la6
         sta la6
         iny
         beq l0619
l0647    lda (l9d),y
l0649    tax
         lda l1237,x
         sta l9f
         txa
         and #$0f
         tax
         lda l0f6f,x
         asl a
         asl a
         asl a
         asl a
         sta la9
         rol l9f
         lda lc1
         and #$c0
         ora l9f
         sta lc1
         iny
l0668    = *+1
l0667    lda #$40
         tax
         lda l1237,x
         lsr a
         ora la9
         sta la9
         txa
         and #$0f
         tax
         lda l0f6f,x
         php
         asl a
         asl a
         asl a
         plp
         ror a
         sta laa
         iny
l0683    = *+1
l0682    lda #$c0
         tax
         lda l1237,x
         lsr a
         ror ld9
         lsr a
         ror ld9
         lsr a
         ror ld9
         ora laa
         sta laa
         txa
         and #$0f
         tax
         lda ld9
         and #$e0
         ora l0f6f,x
         sta ld9
         sty lb1
         ldy lb7
         lda la6
         sta (lb2),y
         iny
         lda lc1
         sta (lb2),y
         iny
         lda la9
         sta (lb2),y
         iny
         lda laa
         sta (lb2),y
         iny
         lda ld9
         sta (lb2),y
         iny
         sty lb7
         dec lb4
         bne l06cf
         lda #$00
         sta lb7
         sta lb2
         lda ldb
         sta lb3
l06cf    lda l0668
         beq l06da
         ldy lb1
         iny
         jmp l0628
l06da    inc la8
         inc l01
l06de    inc lae
         lda #$46
         clc
         adc lb5
         sta lb5
         bcc l06eb
         inc lb6
l06eb    lda lae
         cmp lc0
         beq l06f8
         jmp l0555

l06f4    cpy lc0
         bcc l070b
l06f8    jsr getdb
         beq l0700
         jmp l0446
l0700    ldy #$00
         sty lae
         lda #<l1337
         ldx #>l1337
         dec $dd03
l070b    sec
         sbc #$ba
         bcs l0711
         dex
l0711    sta lb5
         stx lb6
         sta l07cf
         stx l07d0
         lda lba
         bmi l0738
         ldx lae
         jsr l0d59
         ldy lad
         lda (llda),y
         cmp #$3f
         beq l0734
         cmp #$53
         beq l0734
         cmp #$48
         bne l0738
l0734    ldx #$55
         bne l073a
l0738    ldx #$52
l073a    stx $dd01
         ldy lae
         ldx lc3,y
         bmi l0746
         jmp l07c8
l0746    ldy #$ba
         lda #$55
l074a    ldx $dd0d
         beq l074a
         sta $dd01
         lda (lb5),y
l0754    ldx $dd0d
         beq l0754
         sta $dd01
         iny
         lda (lb5),y
l075f    ldx $dd0d
         beq l075f
         sta $dd01
         ldy #$00
l0769    lda $ff00,y
l076c    ldx $dd0d
         beq l076c
         sta $dd01
         iny
         bne l0769
         ldy #$c4
l0779    lda $ff00,y
l077c    ldx $dd0d
         beq l077c
         sta $dd01
         iny
         bne l0779
         lda #$4b
l0789    ldx $dd0d
         beq l0789
         sta $dd01
         lda #$52
l0793    ldx $dd0d
         beq l0793
         sta $dd01
         ldy #$bc
         lda (lb5),y
l079f    ldx $dd0d
         beq l079f
         sta $dd01
         iny
         lda (lb5),y
l07aa    ldx $dd0d
         beq l07aa
         sta $dd01
         lda #$29
l07b4    ldx $dd0d
         beq l07b4
         sta $dd01
         lda #$4a
l07be    ldx $dd0d
         beq l07be
         sta $dd01
         bne l07eb
l07c8    dex
         stx l07df
         ldy #$ba
l07cf    = *+1
l07d0    = *+2
l07ce    lda $ffff,y
l07d1    ldx $dd0d
         beq l07d1
         sta $dd01
         iny
         bne l07ce
         iny
l07df    = *+2
l07dd    lda $ffff,y
l07e0    ldx $dd0d
         beq l07e0
         sta $dd01
         iny
         bne l07dd
l07eb    inc lae
         ldy lae
l07ef    lda $dd0d
         beq l07ef
         ldx lb6
         lda lb5
         inx
         jmp l06f4

l0be8    sta l0667
         stx l0668
         sta l0682
         stx l0683
         rts

ldd      tax
         lda l1237,x
         ora #$60
         sta la6
         txa
         and #$0f
         tax
         lda l0f6f,x
         asl a
         asl a
         asl a
         asl a
         rol la6
         ora #$05
         sta (lb5),y
         dey
         lda la6
         sta (lb5),y
         rts

l0bf5    ldx #$14
         .byte $2c

l0bf8    ldx #$01
         lda #$20
         ldy #$13
l0bfe    sta l0828,x
         inx
         dey
         bne l0bfe
l0c05    rts

l0c06    stx llda
         jsr l0bf8
         lda #$1b
         sta $d011
         lda #$11
         sta $d404
         dec $d404
         ldy #$01
         bne l0c23

l0c1c    stx llda
         jsr l0bf5
         ldy #$14
l0c23    ldx llda
l0c25    lda l00,x
         beq l0c05
         sta l0828,y
         inx
         iny
         bne l0c25

l0d59    lda l0c30,x
         sta llda
         lda l0c45,x
         sta ldb
         rts

l0c5a    .byte $3f,$2b,$48,$53,$49
         .byte $43,$4c,$46,$50,$48

key      .byte 0

         *= $0800

l0800    .byte $a0,$20,$46,$43
         .byte $4f,$50,$59
         .byte $20,$56,$32,$35,$36
         .byte $2e,$30,$30
         .byte $20,$20,$04
         .byte $0f,$0e,$05,$20
         .byte $02,$19,$20
         .byte $54,$57,$41,$20
         .byte $21,$20,$20
         .byte $42,$01,$0e,$0b
         .byte $20,$3a,$20
l0827    .byte $20
l0828    .byte $a0
l0829    .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$20,$20
l084d    .byte $20
l084e    .byte $20
l084f    .byte $20,$a0,$a0
l0852    .byte $a0,$b0,$b0,$b0,$b0
         .byte $b0,$b0,$b0
         .byte $b0,$b0,$b1,$b1,$b1
         .byte $b1,$b1,$b1
         .byte $b1,$b1,$b1,$b1,$b2
         .byte $b2,$b2,$b2
         .byte $b2,$b2,$b2,$b2,$b2
         .byte $b2,$b3,$b3
         .byte $b3,$b3,$b3,$b3,$a0
         .byte $a0,$a0,$a0
l087a    .byte $a0,$b1,$b2,$b3,$b4
         .byte $b5,$b6,$b7
         .byte $b8,$b9,$b0,$b1,$b2
         .byte $b3,$b4,$b5
         .byte $b6,$b7,$b8,$b9,$b0
         .byte $b1,$b2,$b3
         .byte $b4,$b5,$b6,$b7,$b8
         .byte $b9,$b0,$b1
         .byte $b2,$b3,$b4,$b5,$a0
         .byte $a0,$a0,$b0
         .byte $b0
l08a3    .byte $20
l08a4    .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$b0,$b0,$a0
         .byte $b0,$b1,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$b0,$b1,$a0
         .byte $b0,$b2,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$b0,$b2,$a0
         .byte $b0,$b3,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$b0,$b3,$a0
         .byte $b0,$b4,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$b0,$b4,$a0
         .byte $b0,$b5,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$b0,$b5,$a0
         .byte $b0,$b6,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$b0,$b6,$a0
         .byte $b0,$b7,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$b0,$b7,$a0
         .byte $b0,$b8,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$b0,$b8,$a0
         .byte $b0,$b9,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$b0,$b9,$a0
         .byte $b1,$b0,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$b1,$b0,$a0
         .byte $b1,$b1,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$b1,$b1,$a0
         .byte $b1,$b2,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$b1,$b2,$a0
         .byte $b1,$b3,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$b1,$b3,$a0
         .byte $b1,$b4,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$b1,$b4,$a0
         .byte $b1,$b5,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$b1,$b5,$a0
         .byte $b1,$b6,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$b1,$b6,$a0
         .byte $b1,$b7,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$20,$20,$20
         .byte $a0,$a0,$a0
         .byte $a0,$a0,$b1,$b7,$a0
         .byte $b1,$b8,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$a0
         .byte $a0,$a0,$d4,$92,$89
         .byte $85,$93,$ba
l0b94    .byte $b1,$a0,$b1,$b8,$a0
         .byte $b1,$b9,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $a0,$d2
         .byte $85,$90,$81,$89,$92
         .byte $ba
l0bba    .byte $ce,$8f,$a0,$a0,$a0
l0bda    .byte $a0,$c1,$8c,$8c,$a0
         .byte $b1,$b9,$a0,$b2
         .byte $b0,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$20,$20,$20
         .byte $20,$20,$20
         .byte $20,$20,$a0,$c2
         .byte $85,$87,$89,$8e,$ba
lbegpo   .byte $b0,$b1,$a0
         .byte $a0,$c5,$8e,$84,$ba
lendpo   .byte $b3,$b5,$a0,$b2,$b0

l0c30    .byte $a2,$ca
l0c32    .byte $f2,$1a,$42,$6a,$92
         .byte $ba,$e2,$0a
         .byte $32,$5a,$82,$aa,$d2
         .byte $fa,$22,$4a
         .byte $72,$9a,$c2
l0c45    .byte $08,$08,$08,$09,$09
         .byte $09,$09,$09
         .byte $09,$0a,$0a,$0a,$0a
         .byte $0a,$0a,$0a
         .byte $0b,$0b,$0b,$0b,$0b

l0c64    cmp #$1f
         bcs l0c79
         cmp #$19
         bcs l0c76
         cmp #$12
         bcs l0c73
         ldx #$15
         .byte $2c
l0c73    ldx #$13
         .byte $2c
l0c76    ldx #$12
         .byte $2c
l0c79    ldx #$11
         rts

l0c7c    lda #$0b
         sta $d011
l0c81    bit $d011
         bpl l0c81
l0c86    bit $d011
         bmi l0c86
l0c8b    bit $d011
         bpl l0c8b
         rts

l0c91    ldx #te9
         jsr l0c06
l0c96    lda #$7f
         sta $dc00
         cmp $dc01
         beq l0ce0  ; ignore & retry
         lda #$ef
         sta $dc00
         lda $dc01
         cmp #$fd
         beq l0ccc
         lda #$fb
         sta $dc00
         lda $dc01
         cmp #$fd
         bne l0c96
         jsr l0bf8
         jsr waitfd
         lda #$01
         jsr putdb
         lda $dd01
         jsr l0c7c
         jmp l06f8

l0ccc    jsr l0bf8
         jsr waitfd
         lda #$02
         jsr putdb
         lda $dd01
         jsr l0c7c
         jmp l0443

l0ce0    jmp l0145

l0cf1    pha
         jsr l0d59
         ldy lad
l0cf6    lda (llda),y
         bmi l0cff
         pla
         sta (llda),y
         rts
l0cff    pla
         rts

getdb    lda #$00
         sta $dd03
getdb2   lda $dd0d
         beq getdb2
         lda $dd01
         rts

putdb    ldx #$ff
         stx $dd03
putdb2   sta $dd01
waitfd   lda $dd0d
         beq waitfd
         rts

setdr    tax
         lda $dd00
         and #$df
         cpx #1
         bne sjd
         ora #$20
sjd      sta $dd00
         rts


l0d7b    ldy #$00
         sty lbd
         sty ldc
         ldx #cstack
         txs
         ldx #te5
         jsr l0c06
l0d89    ldx begtr
         ldy endtr
nond     lda #0
         sta $dc00
         lda $dc01
         cmp last
         bne dkmd
nsm      cmp $dc01
         beq nsm
         lda #0
jdn      sec
         sbc #1
         bne jdn
         beq nond
dkmd     sta last
         lda #$fe
         sta $dc00
         lda $dc01
         asl a
         asl a
         bcs noendup
         cpy #36
         bcs noendup
         iny
noendup  asl a
         bcs nobegdo
         cpx #2
         bcc nobegdo
         dex
nobegdo  asl a
         bcs nobegup
         inx
         cpx endtr
         bcc nono
         dex
nobegup  asl a
         bcs nono
         dey
         cpy begtr
         bne nono
         iny
nono     stx begtr
         sty endtr
         txa
         ldy #0
fjd      ldx #$b0
mdk      cmp #10
         bcc sethi
         sbc #10
         inx
         bne mdk
sethi    ora #$b0
         sta lbegpo+1,y
         txa
         sta lbegpo,y
         cpy #0
         bne djfr
         ldy #lendpo-lbegpo
         lda endtr
         sec
         sbc #1
         bne fjd
djfr     ldy #1
         lda #$f7
         sta $dc00
         lda $dc01
         cmp #$bf
         beq keyf
         iny
         cmp #$fd
         beq keyf
         iny
         lda #$ef
         sta $dc00
         lda $dc01
         cmp #$7f
         beq keyf
         iny
         lda #$fd
         sta $dc00
         lda $dc01
         cmp #$df
         beq keyf
         iny
         cmp #$fb
         beq keyf
         iny
         lda #$fb
         sta $dc00
         lda $dc01
         cmp #$fb
         beq keyf
         iny
         cmp #$ef
         beq keyf
         iny
         cmp #$bf
         beq keyf
         ldy #0
keyf     sty key
         lda #$ff
         ldy key
         dey
         bne l0df0
         iny
         sty la0
         ldx #te12
l0de3    ldy #$00
l0de5    lda l00,x
         beq l0dd0
         sta l0bda,y
         inx
         iny
         bne l0de5
l0df0    dey
         bne l0d90
         sta lba
         ldx #te14
l0df8    ldy #$00
l0dfa    lda l00,x
         beq l0dd0
         sta l0bba,y
         inx
         iny
         bne l0dfa
l0d90    dey
         bne l0d9d
         sty lba
         ldx #te15
         bne l0df8
l0d9d    dey
         beq l0e0f
         dey
         bne l0db9
         sty la0
         ldx #te13
         bne l0de3
l0db9    dey
         bne l0dcb
         lda #2
         sta ldc
         ldx #te11
         bne l0e17
l0dcb    dey
         beq l0e15
         dey
         bne l0dd0
         lda lb8
         eor #$04
         sta lb8
         ora #$b0
         sta l0b94
l0dd0    jmp l0d89
l0e0f    ldx #te3
         lda #1
         sta ldc
         bne l0e17
l0e15    ldx #te2
l0e17    ldy #$00
l0e1b    jsr l0c1c
         jsr l0e47
         lda ldc
         bne l0e39   ; dir=1,2
         lda #1
         jsr setdr
         lda lb8     ; tries
         jsr putdb
         lda begtr   ; track
         sta lbb
         jsr putdb2
         lda la0     ; all=0
l0e33    jsr putdb2
         lda #0
         jsr putdb2  ; read
         jmp l019c

l0e39    jsr setdr   ; 1=src,2=dest
         lda #$02
         jsr putdb
         lda #$12
         jsr putdb2
         lda #$00
         beq l0e33

l0e47    lda #$23
         sta lad
l0e4e    ldx #$14
         stx la8
l0e52    lda #$20
         ldx la8
         jsr l0cf1
         dec la8
         bpl l0e52
         dec lad
         bne l0e4e
         ldx #$20
         txa
l0e68    sta l08a3,x
         dex
         bpl l0e68
         rts

l0e6f    jsr waitfd
         lda #0
         jsr putdb
         lda l152a
         beq l0e90
         sta l9e
         ldy #$90
         ldx #$00
l0e80    lda (l9d),y
         jsr l0f0a
         ora #$80
         sta l08a4,x
         inx
         iny
         cpx #$14
         bcc l0e80
l0e90    jsr l0f20
         ldy #$01
l0e95    sty lae
         lda l152a,y
         beq l0f07
         sta l9e
         ldy #$02
l0ea0    sty lab
         lda (l9d),y
         bpl l0ef3
         dec lb4
         bne l0ed0
         lda #$7f
         sta $dc00
l0eaf    lda $dc01
         cmp #$7f
         beq l0f07
         cmp #$ef
         bne l0eaf
         ldx #$00
l0ebc    dex
         bne l0ebc
l0ebf    cmp $dc01
         beq l0ebf
         sty lac
         jsr l0e47
         jsr l0f20
         ldy lac
         dec lb4
l0ed0    lda l0eeb
         sec
         adc #$27
         sta l0eeb
         bcc l0ede
         inc l0eec
l0ede    iny
         iny
         iny
         ldx #$00
l0ee3    lda (l9d),y
         jsr l0f0a
         and #$7f
l0eeb    = *+1
l0eec    = *+2
         sta $1a44,x
         iny
         inx
         cpx #$10
         bcc l0ee3
l0ef3    lda lab
         clc
         adc #$20
         tay
         bcc l0ea0
         ldy #$00
         lda (l9d),y
         beq l0f07
         iny
         lda (l9d),y
         tay
         bne l0e95
l0f07    jmp l0d7b

l0f0a    bmi l0f1b
         cmp #$20
         bcc l0f1a
         cmp #$60
         bcc l0f18
         and #$df
         bcs l0f1a
l0f18    and #$3f
l0f1a    rts
l0f1b    and #$7f
         ora #$40
         rts

l0f20    lda #<l08a4
         ldx #>l08a4
         sta l0eeb
         stx l0eec
         lda #$15
         sta lb4
         rts

         *= $0f2f

l0f2f    .byte $ff,$ff,$ff,$ff,$ff
         .byte $ff,$ff,$ff
         .byte $ff,$08,$00,$01,$ff
         .byte $0c,$04,$05
         .byte $ff,$ff,$02,$03,$ff
         .byte $0f,$06,$07
         .byte $ff,$09,$0a,$0b,$ff
         .byte $0d,$0e,$ff
l0f4f    .byte $ff,$ff,$ff,$ff,$ff
         .byte $ff,$ff,$ff
         .byte $ff,$80,$00,$10,$ff
         .byte $c0,$40,$50
         .byte $ff,$ff,$20,$30,$ff
         .byte $f0,$60,$70
         .byte $ff,$90,$a0,$b0,$ff
         .byte $d0,$e0,$ff
l0f6f    .byte $0a,$0b,$12,$13,$0e
         .byte $0f,$16,$17
         .byte $09,$19,$1a,$1b,$0d
         .byte $1d,$1e,$15

l0f7f    = $0f7f
l1067    = $1067
l114f    = $114f
l1237    = $1237
l1337    = l1237+$0100
l1300    = $1300
l13b8    = $13b8
l13b9    = $13b9
l13ba    = $13ba
l13fe    = $13fe
l13ff    = $13ff
l1400    = $1400
l1500    = $1500
l1515    = $1515
l152a    = $152a
l153f    = $153f
l1554    = $1554

         *= *+coff
         .offs 0

l5f80    .byte $13,$0f,$00,$00,$00
         .byte $60,$f9,$00,$00,$00
         .byte $00,$00,$00,$00,$00
         .byte $00,$00,$00,$00,$00
         .byte $00,$00,$00,$00,$0f

l6100    .byte $0a,$0a,$0a,$0a,$0a
         .byte $0a,$0a,$0a
         .byte $0a,$0a,$0a,$0a,$0a
         .byte $0a,$0a,$0a
         .byte $0b,$0b,$0b,$0b,$0b
         .byte $0b,$0b,$0b
         .byte $0b,$0b,$0b,$0b,$0b
         .byte $0b,$0b,$0b
         .byte $12,$12,$12,$12,$12
         .byte $12,$12,$12
         .byte $12,$12,$12,$12,$12
         .byte $12,$12,$12
         .byte $13,$13,$13,$13,$13
         .byte $13,$13,$13
         .byte $13,$13,$13,$13,$13
         .byte $13,$13,$13
         .byte $0e,$0e,$0e,$0e,$0e
         .byte $0e,$0e,$0e
         .byte $0e,$0e,$0e,$0e,$0e
         .byte $0e,$0e,$0e
         .byte $0f,$0f,$0f,$0f,$0f
         .byte $0f,$0f,$0f
         .byte $0f,$0f,$0f,$0f,$0f
         .byte $0f,$0f,$0f
         .byte $16,$16,$16,$16,$16
         .byte $16,$16,$16
         .byte $16,$16,$16,$16,$16
         .byte $16,$16,$16
         .byte $17,$17,$17,$17,$17
         .byte $17,$17,$17
         .byte $17,$17,$17,$17,$17
         .byte $17,$17,$17
         .byte $09,$09,$09,$09,$09
         .byte $09,$09,$09
         .byte $09,$09,$09,$09,$09
         .byte $09,$09,$09
         .byte $19,$19,$19,$19,$19
         .byte $19,$19,$19
         .byte $19,$19,$19,$19,$19
         .byte $19,$19,$19
         .byte $1a,$1a,$1a,$1a,$1a
         .byte $1a,$1a,$1a
         .byte $1a,$1a,$1a,$1a,$1a
         .byte $1a,$1a,$1a
         .byte $1b,$1b,$1b,$1b,$1b
         .byte $1b,$1b,$1b
         .byte $1b,$1b,$1b,$1b,$1b
         .byte $1b,$1b,$1b
         .byte $0d,$0d,$0d,$0d,$0d
         .byte $0d,$0d,$0d
         .byte $0d,$0d,$0d,$0d,$0d
         .byte $0d,$0d,$0d
         .byte $1d,$1d,$1d,$1d,$1d
         .byte $1d,$1d,$1d
         .byte $1d,$1d,$1d,$1d,$1d
         .byte $1d,$1d,$1d
         .byte $1e,$1e,$1e,$1e,$1e
         .byte $1e,$1e,$1e
         .byte $1e,$1e,$1e,$1e,$1e
         .byte $1e,$1e,$1e
         .byte $15,$15,$15,$15,$15
         .byte $15,$15,$15
         .byte $15,$15,$15,$15,$15
         .byte $15,$15,$15
ttoten

