1000         *=      $0600         ; program origin Ы1010 ; Ы1020 ; SYMBOL EQUATES Ы1030 ; Ы1040 EOL     =       $9B           ; end-of-line symbol Ы1050 ; Ы1060 ; ADDRESS EQUATES Ы1070 ; Ы1080 WARMST  =       $08           ; warm start flag Ы1090 BOOTQ   =       $09           ; boot flag Ы1100 ICAX1Z  =       $2A           ; direction byte Ы1110 ICAX6Z  =       $2F           ; put byte storage Ы1120 BPTR    =       $3D           ; buffer pointer Ы1130 FTYPE   =       $3E           ; input/output flag Ы1140 DCB     =       $0300         ; data control block Ы1150 DCOMND  =       $0302         ; command byte Ы1160 DAUX1   =       $030A         ; sector LSB Ы1170 DAUX2   =       $030B         ; sector MSB Ы1180 HATABS  =       $031A         ; handler table Ы1190 CASBUF  =       $0400         ; cassette buffer Ы1200 DSKINV  =       $E453         ; disk interface routine Ы1210 ; Ы1220 ; HEADER BYTES Ы1230 ; Ы1240 PST     .BYTE   0             ; boot header Ы1250         .BYTE   2             ; sector count Ы1260         .WORD   PST           ; program start Ы1270         .WORD   PINIT         ; program init Ы1280         CLC                   ; good boot Ы1290         RTS                   ; return Ы1300 ; Ы1310 ; BASIC ENTRY Ы1320 ; Ы1330         PLA                   ; pull arg count Ы1340 ; Ы1350 ; CASSETTE HANDLER SWAP Ы1360 ; Ы1370 PINIT   LDA     #$43          ; look for "C: Ы1380         LDX     #0            ; first handler Ы1390         STX     CHKSTA+1      ; clear I/O state Ы1400 FINHND  CMP     HATABS,X      ; check handler Ы1410         BEQ     FNDHND        ; if found Ы1420 ; Ы1430         INX                   ; otherwise, next handler Ы1440         INX Ы1450         INX Ы1460         BNE     FINHND Ы1470 ; Ы1480 FNDHND  LDA     #NEWTAB&$FF   ; set new table Ы1490         STA     HATABS+1,X Ы1500         LDA     #NEWTAB/256   ; also set MSB Ы1510         STA     HATABS+2,X Ы1520         RTS                   ; return Ы1530 ; Ы1540 ; OPEN FILE HANDLER Ы1550 ; Ы1560 OPNFIL  LDA     ICAX1Z        ; check direction Ы1570         LDX     #$03          ; if new direction, Ы1580         LDY     #0            ;   start at sector #3 Ы1590 CHKSTA  CMP     #0            ; check against old Ы1600         BNE     RESET         ;  direction Ы1610 ; Ы1620 SAUX1   LDX     #0            ; old sector number Ы1630 SAUX2   LDY     #0 Ы1640         INX                   ; increment sector Ы1650         BNE     RESET Ы1660 ; Ы1670         INY Ы1680 ; Ы1690 RESET   STX     CASBUF+$7E    ; store sector number Ы1700         STY     CASBUF+$7D Ы1710         STA     CHKSTA+1      ; save direction state Ы1720         ORA     #$F7          ; =$FF for write Ы1730         STA     BPTR          ; save for new pointer Ы1740         LDA     #$7D          ; starting length Ы1750         STA     BYTCNT+1      ; save length Ы1760         LDY     #1            ; good status Ы1770         RTS                   ; return Ы1780 ; Ы1790 ; CLOSE FILE HANDLER Ы1800 ; Ы1810 CLSFIL  BIT     FTYPE         ; check I/O type Ы1820         BPL     DUMMY         ; do nothing if read Ы1830 ; Ы1840         LDA     BPTR          ; prepare for final Ы1850         ORA     #$80          ;  sector output Ы1860         TAX Ы1870         BNE     INCBYT        ; output last sector Ы1880 ; Ы1890 ; GET/PUT BYTE HANDLER Ы1900 ; Ы1910 GETBYT  LDY     #$40          ; input direction Ы1920         BNE     SAVDIR Ы1930 ; Ы1940 PUTBYT  LDY     #$80          ; output direction Ы1950         STA     ICAX6Z        ; save output byte Ы1960 SAVDIR  STY     FTYPE         ; save direction Ы1970         LDX     BPTR          ; get pointer Ы1980 INCBYT  INX                   ; increment Ы1990         STX     BPTR          ; save pointer Ы2000 BYTCNT  CPX     #$7D          ; check for sector end Ы2010         BCS     ENDSEC        ; perform I/O Ы2020 ; Ы2030         LDA     ICAX6Z        ; get output byte Ы2040         BIT     FTYPE         ; if output, store Ы2050         BMI     STORE Ы2060 ; Ы2070         LDA     CASBUF,X      ; otherwise, read Ы2080 STORE   STA     CASBUF,X      ;  and store Ы2090 DUMMY   LDY     #1            ; good status Ы2100         RTS                   ; return Ы2110 ; Ы2120 ; FORMAT DCB Ы2130 ; Ы2140 FMTBLK  .BYTE   $31,$01       ; format block for init Ы2150         .BYTE   $21,$00 Ы2160         .WORD   CASBUF Ы2170 ; Ы2180         *=      $680          ; allow for flag bytes Ы2190 ;                             ;  from init routine Ы2200 ENDSEC  LDA     CASBUF+$7D    ; get sector Ы2210         AND     #$03 Ы2220         STA     DAUX2         ; save to DCB sector Ы2230         TAY                   ; save for later Ы2240         LDA     CASBUF+$7E    ; also do MSB Ы2250         STA     DAUX1 Ы2260         TAX                   ; save for later Ы2270         ORA     DAUX2         ; check for last Ы2280         BEQ     ERROR         ; if so, end-of-file Ы2290 ; Ы2300         STX     SAUX1+1       ; save sector for open Ы2310         STY     SAUX2+1 Ы2320         LDX     #$05          ; set up DCB Ы2330 SETDCB  LDA     RDSEC,X Ы2340         STA     DCB,X Ы2350         DEX Ы2360         BPL     SETDCB Ы2370 ; Ы2380         BIT     FTYPE         ; check for write Ы2390         BPL     GODISK        ; if not, go ahead Ы2400 ; Ы2410         LDA     #$57          ; change command to write Ы2420         STA     DCOMND Ы2430         LDA     BPTR          ; check for last sector Ы2440         BPL     STBPTR Ы2450 ; Ы2460         LDX     #$FF          ; clear sector Ы2470         STX     CASBUF+$7D Ы2480         STX     CASBUF+$7E Ы2490 STBPTR  STA     CASBUF+$7F    ; save byte count Ы2500         INC     CASBUF+$7E    ; increment sector link Ы2510         BNE     GODISK Ы2520 ; Ы2530         INC     CASBUF+$7D Ы2540 GODISK  JSR     DSKINV        ; perform I/O Ы2550         BPL     SETSEC Ы2560 ; Ы2570 ERROR   LDY     #$88          ; error or end-of-file Ы2580         RTS Ы2590 ; Ы2600 SETSEC  LDA     CASBUF+$7F    ; get byte count Ы2610         AND     #$7F Ы2620         STA     BYTCNT+1      ; save Ы2630         LDX     #$FF          ; set for first byteЫ2640         BNE     INCBYT        ; return Ы2650 ; Ы2660 ; READ SECTOR DCB Ы2670 ; Ы2680 RDSEC   .BYTE   $31,$01       ; DCB for read sector Ы2690         .BYTE   $52,$00 Ы2700         .WORD   CASBUF Ы2710 ; Ы2720 ; HANDLER TABLE Ы2730 ; Ы2740 NEWTAB  .WORD   OPNFIL-1      ; open handler Ы2750         .WORD   CLSFIL-1      ; close handler Ы2760         .WORD   GETBYT-1      ; get byte handler Ы2770         .WORD   PUTBYT-1      ; put byte handler Ы2780         .WORD   DUMMY-1       ; rest dummy Ы2790         .WORD   DUMMY-1 Ы2800         JMP     DUMMY Ы2810 ; Ы2820 ; FORMAT DISK Ы2830 ; Ы2840         PLA                   ; for BASIC call Ы2850         LDX     #$05          ; move format block Ы2860 MVFMT   LDA     FMTBLK,X      ;  to DCB Ы2870         STA     DCB,X Ы2880         DEX Ы2890         BPL     MVFMT Ы2900 ; Ы2910         JMP     DSKINV        ; format and return Ы2920 ; Ы2930         .END ЫЫЫ