8-Bit Software Online Conversion

Scan Disc ADFS - Listing

10 REM Scandisk drive [,drive] 20 MODE6 30 HIMEM=HIMEM-&1000 40 OSRDCH=&FFE0 50 OSASCI=&FFE3 60 OSWORD=&FFF1 70 buffer=&70 80 FORI%=0 TO 3 STEP 3 90 P%=&900 100 [OPTI% 110 .scandisk 120 LDY #0 130 .findend 140 LDA(&F2),Y:INY:CMP#13:BEQhelp:CMP# 32:BNE findend:BEQ findd1 150 .help 160 JSR print 170 EQUB10 180 EQUS"ADFS Scandisk " 190 EQUW&0A0D 200 EQUS"*Scandisk drive [,drive]" 210 EQUW&0A0D 220 EQUB0 230 RTS ½ Retur n to Basic 310 .findd1 320 LDA(&F2),Y:CMP #32:BNE gck1 330 .skip1 340 INY:LDA(&F2),Y:CMP #32:BEQ skip1 350 .gck1 360 CMP#13:BNE clrbuf1:JMP help 370 .clrbuf1 380 LDA #32:LDX #16 390 .clr1 400 DEX:STA buffer,X:BNE clr1 410 .getd1 420 LDA (&F2),Y:STA buffer,X 430 INY:INX 440 CMP #13:BNE getd1 450 460 .loop 470 LDX xstore 480 LDA buffer,X:INX:STX xstore 490 CMP #13:BEQ end 500 CMP #32:BEQ loop 510 CMP #44:BEQ loop 520 JSR do:JMP loop 530 .end 540 LDA #13:JSR OSASCI 550 RTS ½ Retur n to Basic 560 .do 570 SEC:SBC #48:CMP #6:BMI valid:JMP h elp 580 .valid 590 PHA 600 ASL A:ASL A:ASL A:ASL A:ASL A 610 STA drive 612 LDA #0:STA from`mid:STA from`low 614 LDA #48:STA errcnt 620 JSR print 630 EQUB&0D 640 EQUS"Scanning :" 650 EQUB0 660 PLA:CLC:ADC #48:JSR OSASCI 662 LDA #32:JSR OSASCI:LDA #38:JSR OSA SCI:JSR pabsolute 670 JSR osword 680 LDA block:BEQ ok1:JSR doerror ½ error check 690 .ok1 700 LDA HIMEM+&FD:STA hisize 710 LDA HIMEM+&FC:STA losize 720 730 .loop2 740 CLC:LDA from`low:ADC #&10:STA from `low:BCC nohi:INC from`mid 750 .nohi 752 LDA from`low:CMP losize:BNE notend 770 LDA from`mid:CMP hisize:BCS out1 771 .notend 772 JSR pabsolute 780 JSR osword 790 LDA block:BEQ ok2 ½ error check 800 JSR doerror:BCS out2 810 .ok2 820 JMP loop2 822 .out1 830 LDA errcnt:CMP #48:BNE out2 831 JSR print 832 EQUW&0909 833 EQUW&0909 834 EQUW&0909 835 EQUW&0909 836 EQUS"ok" 837 EQUB0 838 RTS 839 .out2 840 JSR print 841 EQUW&0909 842 EQUW&0909 843 EQUW&0909 844 EQUW&0909 845 .errcnt EQUB 48 846 EQUS" errors" 847 EQUB0 848 RTS 850 860 .doerror 870 INC errcnt:LDA errcnt:CMP #57:BCS errend 872 LDA #10:JSR OSASCI 874 LDA #8:JSR OSASCI 876 LDA #38:JSR OSASCI 878 JSR pabsolute 879 .errend 880 RTS 890 900 .phex 910 PHA 912 LSR A:LSR A:LSR A:LSR A 920 JSR conv 930 PLA:AND #&0F 940 JSR conv:CLC:RTS 950 .conv 960 SED:CLC 970 ADC #&90:ADC #&40 980 CLD:JSR OSASCI:RTS 990 1000 .pabsolute 1010 LDA drive:AND #&1F:JSR phex 1020 LDA from`mid:JSR phex 1030 LDA from`low:JSR phex 1040 LDA #8:JSR OSASCI:JSR OSASCI 1050 JSR OSASCI:JSR OSASCI 1060 JSR OSASCI:JSR OSASCI 1070 RTS 1080 1100 .print 1110 LDY #0:PLA:STA pr1+2:PLA:STA pr1+3 1120 .pr1 1130 INY:LDA &FFFF,Y ½DUMMY 1140 JSR &FFE3:BNE pr1 1150 TYA:CLC:ADC pr1+2:TAX:BCC pr2:INC pr1+3 1160 .pr2 1170 LDA pr1+3:PHA:TXA:PHA:RTS 1180 .osword 1190 LDA #&72:LDX #block MOD &100:LDY # block DIV &100:JSR OSWORD:RTS 1200 .block 1210 EQUB 0 ½ retur n report non zero = error 1220 EQUB HIMEM MOD &100 ½ point er to data LSB 1230 EQUB HIMEM DIV &100 ½ 1240 EQUB 0 ½ 1250 EQUB 0 ½ point er to data MSD 1260 EQUB 8 ½ comma nd 8 = read 10 = write 1270 .drive EQUB 0 ½ bits 0-4 = from`hi bits 5-7 = drive 1280 .from`mid EQUB 0 ½ absol ute sector address 1290 .from`low EQUB 0 1300 EQUB 16 ½ numbe r of sectors to read 1310 EQUB 0 ½ not u sed 1320 EQUB 0 ½ data length for write LSB 1330 EQUB 0 ½ 1340 EQUB 0 ½ 1350 EQUB 0 ½ data length for write MSB 1360 .losize EQUB0 1370 .hisize EQUB0 1380 .xstore EQUB0 1400 ] 1410 NEXT 1420 PRINT'" *SAVE Scandisk "STR$÷scand isk" "STR$÷P%