8-Bit Software Online Conversion

:2.S.FORM+V - Listing

10 REM FORM <tracks> <drive> 20 OSRDCH=&FFE0 30 OSASCI=&FFE3 40 OSWORD=&FFF1 50 TCOUNT=&3FAF 60 TSECT=&3F9B 90 DRIVE1=&3F9E 100 DRIVE=&3F9F 110 TRACK=&3F9D 120 SIDE=&3F9C 130 LOSIZE=&3FAB 140 HISIZE=&3FAC 150 FORI%=0 TO 2 STEP 2 160 P%=&3200 170 [OPTI% 180 .form 190 LDY #0 200 .findend 210 LDA(&F2),Y:INY:CMP#13:BEQhelp:CMP# 32:BNE findend:BEQ findd1 220 .help 230 JSR print 240 EQUB10 250 EQUS"DFS disk format and verify " 260 EQUW&0A0D 270 EQUB10 280 EQUS"*FORM <tracks> <drive>" 340 EQUW&0A0D 350 EQUW&000A 360 RTS 370 .findd1 380 LDA(&F2),Y:CMP #32:BNE gck1 390 .skip1 400 INY:LDA(&F2),Y:CMP #32:BEQ skip1 410 .gck1 420 CMP#13:BNE clrbuf1:JMP help 430 .clrbuf1 440 LDA #32:LDX #16 450 .clr1 460 DEX:STA buffer,X:BNE clr1 470 .getd1 480 LDA (&F2),Y:STA buffer,X 490 INY:INX 500 CMP #13:BEQ fault 510 CMP #32:BNE getd1:BEQ findd2 520 .fault 530 BRK:EQUB 128 540 EQUS "NO drive specified !!!" 550 EQUB 0 560 .findd2 570 LDA(&F2),Y:CMP #32:BNE gck2 580 .skip2 590 INY:LDA (&F2),Y:CMP #32:BEQ skip2 600 .gck2 610 CMP#13:BEQ fault 620 LDA #32:LDX #16 630 .clr2 640 DEX:STA buffer2,X:BNE clr2 650 .getd2 660 LDA (&F2),Y:STA buffer2,X 670 INY:INX 680 CMP #13:BEQ ok 690 CMP #32:BNE getd2 700 .ok 710 JSR print 720 EQUB10 730 EQUS"Press any key when ready" 740 EQUW&0A0D 750 EQUW &000A 760 JSR OSRDCH 770 LDX #0 780 LDA buffer,X:CMP #ASC("4"):BEQ T40 790 LDA #80:STA TCOUNT 800 LDA #&20:STA LOSIZE 810 LDA #3:STA HISIZE:BNE gside 820 .T40 830 LDA #40:STA TCOUNT 840 LDA #&90:STA LOSIZE 850 LDA #1:STA HISIZE 860 .gside 870 LDA buffer2,X:SEC:SBC #48 875 CMP #4:BMI store:JMP fault 878 .store 880 STA DRIVE:STX SIDE 890 SEC:SBC #2:BMI s0:INC SIDE 900 .s0 910 STX TRACK:STX FERR+1:STX VERR+1 920 LDA #10:STA TSECT 930 .START 940 JSR IDFIELD ½ Set format data 950 JSR DCHAR 960 JSR CMDPAR ½ Set up format cmd 970 LDA #&7F:LDX #&80:LDY #&3F 980 JSR OSWORD 990 LDA &3F8C ½ Get error code 1000 CMP #0:BEQ LPV1:INC FERR+1 1010 LDA #&3F:JSR OSASCI ½ PRINT"?" 1020 JMP LPV2 1030 .LPV1 1040 LDA #&20:JSR OSASCI ½ PRINT" " 1050 .LPV2 1060 JSR VER ½ Set up verify cmd 1070 LDA #&7F:LDX #&90:LDY #&3F 1080 JSR OSWORD 1090 LDA &3F9A ½ Get error code 1100 CMP #0:BEQ LPV3:INC VERR+1 1110 LDA #&3F:JSR OSASCI ½ PRINT"?" 1120 JMP LPV4 1130 .LPV3 1140 LDA #&20:JSR OSASCI ½ PRINT" " 1150 .LPV4 1160 INC TRACK:LDA TRACK 1170 CMP TCOUNT:BNE START 1180 1200 JSR DIRDATA ½ Set up directory 1210 JSR DIRINIT ½ Set up directory cmd 1220 LDA #&7F:LDX #&A0:LDY #&3F 1230 JSR OSWORD 1240 LDA &3FAA ½ Get error code 1250 CMP #0:BEQ LPV5:INC FERR+1 1260 .LPV5 1270 LDA #0:STA TRACK 1280 JSR VER ½ Set verify cmd 1290 LDA #&7F:LDX #&90:LDY #&3F 1300 JSR OSWORD 1310 LDA &3F9A ½ Get error code 1320 CMP #0:BEQ LPV6:INC VERR+1 1330 .LPV6 1332 JSR &FFE7 1334 .FERR 1336 LDA #0:JSR DCHAR+3 1340 JSR print 1360 EQUS" format errors " 1365 EQUW&0A0D 1370 EQUB0 1372 .VERR 1374 LDA #0:JSR DCHAR+3 1390 JSR print 1400 EQUS" verify errors " 1410 EQUB0 1422 JSR &FFE7:JSR &FFE7 1430 RTS ½ Return to basic 1440 1450 .CMDPAR 1460 LDX #0:LDA DRIVE:STA &3F80,X 1470 INX:LDA #&B0:STA &3F80,X 1480 INX:LDA #&3F:STA &3F80,X 1490 INX:LDA #&00:STA &3F80,X 1500 INX:STA &3F80,X 1510 INX:LDA #&05:STA &3F80,X 1520 INX:LDA #&63:STA &3F80,X 1530 INX:LDA TRACK:STA &3F80,X 1540 INX:LDA #21:STA &3F80,X 1550 INX:LDA #&2A:STA &3F80,X 1560 INX:LDA #&00:STA &3F80,X 1570 INX:LDA #&10:STA &3F80,X 1580 INX:LDA #&FF:STA &3F80,X 1590 RTS 1600 .VER 1610 LDX #0:LDA DRIVE:STA &3F90,X 1620 INX:LDA #&00:STA &3F90,X 1630 INX:STA &3F90,X 1640 INX:STA &3F90,X 1650 INX:STA &3F90,X 1660 INX:LDA #&03:STA &3F90,X 1670 INX:LDA #&5F:STA &3F90,X 1680 INX:LDA TRACK:STA &3F90,X 1690 INX:LDA #&00:STA &3F90,X 1700 INX:LDA #&2A:STA &3F90,X 1710 INX:LDA #&FF:STA &3F90,X 1720 RTS 1730 .DIRINIT 1740 LDX #0:LDA DRIVE:STA &3FA0,X 1750 INX:LDA #&00:STA &3FA0,X 1760 INX:LDA #&40:STA &3FA0,X 1770 INX:LDA #&00:STA &3FA0,X 1780 INX:STA &3FA0,X 1790 INX:LDA #&03:STA &3FA0,X 1800 INX:LDA #&4B:STA &3FA0,X 1810 INX:LDA #&00:STA &3FA0,X 1820 INX:STA &3FA0,X 1830 INX:LDA #&22:STA &3FA0,X 1840 INX:LDA #&FF:STA &3FA0,X 1850 RTS 1860 .IDFIELD 1870 LDY #0:LDX #0 1880 .LOOP 1890 LDA TRACK:STA &3FB0,X 1900 INX:LDA SIDE:STA &3FB0,X 1910 INX:TYA:STA &3FB0,X 1920 INX:LDA #&01:STA &3FB0,X 1930 INX:INY 1940 CPY TSECT:BNE LOOP 1950 RTS 1960 .DIRDATA 1970 LDY #&FF:LDX #0 1980 .DLP1 1990 LDA #0:STA &4000,X 2000 INX:DEY:TYA 2010 CMP #0:BNE DLP1 2020 LDY #&FF 2030 .DLP2 2040 LDA #0:STA &4100,X 2050 INX:DEY:TYA 2060 CMP #0:BNE DLP2 2070 LDA HISIZE:STA &4106 2080 LDA LOSIZE:STA &4107 2090 RTS 2100 .DCHAR 2110 LDA TRACK:TAY 2120 LDX #&FE 2130 ROR A:ROR A:ROR A:ROR A 2140 .CHAR2 2150 AND #&0F 2160 SEC:SBC #&0A:BCS TX1 2170 ADC #&3A:BCS TX2 2180 .TX1 2190 ADC #&40 2200 .TX2 2210 JSR OSASCI 2220 INX:BEQ TX3 2230 TYA:JMP CHAR2 2240 .TX3 2250 RTS 2260 .print 2270 LDY #0:PLA:STA pr1+2:PLA:STA pr1+3 2280 .pr1 2290 INY:LDA &FFFF,Y ½DUMMY 2300 JSR &FFE3:BNE pr1 2310 TYA:CLC:ADC pr1+2:TAX:BCC pr2:INC pr1+3 2320 .pr2 2330 LDA pr1+3:PHA:TXA:PHA:RTS 2340 .buffer EQUS "XXXXXXXXXXXXXXXX":EQ UB13 2350 .buffer2 EQUS "XXXXXXXXXXXXXXXX":E QUB13 2360 ] 2370 NEXT 2380 REM OSCLI"*SAVE FORM+V "+STR$÷form +" "+STR$÷P%