10       .OPT NO LIST›20 ;******** DSWAP **************›30 ;REASSIGN DIRVES ON THE MIO›40 ;     BY ED BACHMAN›50 ;         10/86›60 ;*****************************›70 ;revised 2/87,5/87,9/87,1/88›80 ;6/88,10/88,2/89›90 ;›0100 ;*****************************›0110 ;        EQUATES›0120 DRIDATA = $D610›0130 RAMUSGLO = $D658›0140 RAMUSGHI = $D660›0150 DRITYPE = $D680›0160 RAMENHI = $D1E2›0170 RAMENLO = $D1E0›0180 ;›0190 Z_CRUNCH = 4›0200 COM_ADD = 36›0210 ;›0220 ICCOM = $0342›0230 ICBAL = $0344›0240 ICBAH = $0345›0250 ICBLL = $0348›0260 ICBLH = $0349›0270 ICAX1 = $034A›0280 ICAX2 = $034B›0290 CIOV =  $E456›0300 ;›0310 ;›0320 IDB1 =  $0700›0330 IDB2 =  $0701›0340 ;›0350 DOSVEC = $0A›0360 ;›0370 ;****************************›0380     *=  $4000›0390 BEGINNING›0400     CLD ›0410 ;NO RERUN!!!›0420     LDA $60›0430     STA BEGINNING›0440     TSX ›0450     STX OLD_STACK_PTR›0460 ;INTRO MESSAGE PRINT›0470     LDA # >INTRO1›0480     LDY # <INTRO1›0490     JSR PRINT›0500     LDA # >INTRO2›0510     LDY # <INTRO2›0520     JSR PRINT›0530     LDA # >MESSG1C›0540     LDY # <MESSG1C›0550     JSR PRINT›0560 ;›0570 ;FIRST CHECK DOS TYPE...›0580     JSR IDCHECK›0590     CPY #0›0600     BEQ CHECK2›0610     JMP DOSERR›0620 CHECK2›0630 ;here we set up our indirect addresses n stuff›0640     LDY #Z_CRUNCH›0650     LDA (DOSVEC),Y›0660     STA ZCRNAME+1›0670     INY ›0680     LDA (DOSVEC),Y›0690     STA ZCRNAME+2›0700 ;›0710 ;›0720 ;›0730 ;FIRST PULL IN PARAMETERS›0740 ;›0750     JSR ZCRNAME›0760     BNE NXTA›0770     JMP ERROR1›0780 NXTA›0790 ;IF WERE HERE THEN CHK PARAMS.›0800 ;›0810     LDY #COM_ADD›0820     LDA (DOSVEC),Y›0830     CMP #$2F›0840     BEQ NXTB›0850     JMP ERROR4›0860 NXTB›0870 ;NOW PULL IN THE DN'S CHK IF VALID <1-8>****›0880 ;›0890     INY ›0900     LDA (DOSVEC),Y›0910     STA SOURCE›0920     STA FD_1›0930     INY ›0940     LDA (DOSVEC),Y›0950     STA DEST›0960     STA FD_2›0970     INY ›0980     LDA (DOSVEC),Y›0990     CMP #$53›1000     BNE NOSAV›1010     LDA #$01›1020     STA SAVFLAG›1030     JMP CONT1›1040 NOSAV›1050     LDA #0›1060     STA SAVFLAG›1070 CONT1›1080     LDA SOURCE›1090     CMP DEST›1100     BNE CONT2›1110     JMP ERROR3›1120 CONT2›1130 ;›1140     LDA SOURCE›1150     JSR INPUT_TEST›1160     STA SOURCE›1170 ;›1180     LDA DEST›1190     JSR INPUT_TEST›1200     STA DEST›1210 ;›1220 ;CHECK SAVE CWD FLAG AND DO IT›1230 ;IF FLAG IS SET.›1240 ;›1250     LDA SAVFLAG›1260     BEQ NO_SAVE›1270     JSR CD_SAVE›1280     CPY #0›1290     BEQ NO_SAVE›1300     LDA #0›1310     STA SAVFLAG›1320 NO_SAVE›1330 ;›1340 ;CALC BOTH DRIVE OFFSETS›1350 ;›1360     LDA SOURCE›1370     JSR CALC_OFFSET›1380     STA OFSET1›1390 ;›1400     LDA DEST›1410     JSR CALC_OFFSET›1420     STA OFSET2›1430 ;›1440 ;NOW ENABLE THE $D6XX RAM WINDOW›1450 ;SET THE ADDR TO PAGE 0-MIO›1460 ;›1470     JSR MIO_ON›1480 ;›1490 ;NOW WRITE SOURCE AND DEST DRIVE INFO TO THEIR BUFFERS›1500 ;›1510     LDY #0›1520     LDX OFSET1›1530 LOOP1›1540     LDA DRIDATA,X›1550     STA BUFF1A,Y›1560     LDA DRITYPE,X›1570     STA BUFF1B,Y›1580     INX ›1590     INY ›1600     CPY #$08›1610     BNE LOOP1›1620 ;›1630     LDX SOURCE›1640     LDA RAMUSGLO,X›1650     STA B_1CLO›1660     LDA RAMUSGHI,X›1670     STA B_1CHI›1680 ;›1690 ;›1700 ;NOW THE DEST DRIVE...›1710 ;›1720     LDY #0›1730     LDX OFSET2›1740 LOOP3›1750     LDA DRIDATA,X›1760     STA BUFF2A,Y›1770     LDA DRITYPE,X›1780     STA BUFF2B,Y›1790     INX ›1800     INY ›1810     CPY #$08›1820     BNE LOOP3›1830 ;›1840     LDX DEST›1850     LDA RAMUSGLO,X›1860     STA B_2CLO›1870     LDA RAMUSGHI,X›1880     STA B_2CHI›1890 ;›1900 ;OK NOW PUT THEM BACK ON PAGE 0›1910 ;›1920     LDY #0›1930     LDX OFSET1›1940 LOOP5›1950     LDA BUFF2A,Y›1960     STA DRIDATA,X›1970     LDA BUFF2B,Y›1980     STA DRITYPE,X›1990     INX ›2000     INY ›2010     CPY #$08›2020     BNE LOOP5›2030 ;›2040     LDX SOURCE›2050     LDA B_2CLO›2060     STA RAMUSGLO,X›2070     LDA B_2CHI›2080     STA RAMUSGHI,X›2090 ;›2100 ;ONE MORE DRIVE...›2110 ;›2120     LDY #0›2130     LDX OFSET2›2140 LOOP7›2150     LDA BUFF1A,Y›2160     STA DRIDATA,X›2170     LDA BUFF1B,Y›2180     STA DRITYPE,X›2190     INX ›2200     INY ›2210     CPY #$08›2220     BNE LOOP7›2230 ;›2240     LDX DEST›2250     LDA B_1CLO›2260     STA RAMUSGLO,X›2270     LDA B_1CHI›2280     STA RAMUSGHI,X›2290 ;›2300 ;OK THATS IT! NOW CLOSE THE MIO›2310 ;›2320     JSR MIO_OFF›2330 ;›2340 ;CHECK SAVE CD FLAG›2350 ;›2360     LDA SAVFLAG›2370     BEQ NO_1›2380     JSR DIR_RESTORE›2390     LDA # >MESSG5›2400     LDY # <MESSG5›2410     JSR PRINT›2420 NO_1›2430 ;›2440 ;DONE RETURN TO DOS.›2450 ;›2460     LDA # >MESSG9›2470     LDY # <MESSG9›2480     JSR PRINT›2490     RTS ›2500 ;›2510 ;TEST FOR DOS TYPE›2520 ;›2530 IDCHECK›2540     LDA IDB1›2550     CMP #$53›2560     BNE NOGOOD›2570     LDA IDB2›2580     SEC ›2590     SBC #$32›2600     BCC NOGOOD›2610     LDY #0›2620     RTS ›2630 NOGOOD›2640     LDY #1›2650     RTS ›2660 ;›2670 ;›2680 MIO_ON›2690     SEI ›2700     LDA #0›2710     STA RAMENLO›2720     LDA #$20›2730     STA RAMENHI›2740     CLI ›2750     RTS ›2760 ;›2770 MIO_OFF›2780     SEI ›2790     LDA #0›2800     STA RAMENHI›2810     CLI ›2820     RTS ›2830 ;›2840 INPUT_TEST›2850     SEC ›2860     SBC #$31›2870     BCS IT_STEP1›2880     JMP ERROR2›2890 IT_STEP1›2900     TAX ›2910     SEC ›2920     SBC #8›2930     BCC IT_STEP2›2940     JMP ERROR2›2950 IT_STEP2›2960     TXA ›2970     RTS ›2980 ;›2990 CALC_OFFSET›3000     STA CALC_TEST›3010     LDA #0›3020     TAX ›3030 CO_LOOP›3040     CPX CALC_TEST›3050     BNE CT_NOTYET›3060     RTS ›3070 CT_NOTYET›3080     CLC ›3090     ADC #8›3100     INX ›3110     JMP CO_LOOP›3120 ;›3130 ZCRNAME›3140     JMP $FFFF›3150 ;›3160 ;›3170 ;***************************›3180 ;›3190 CD_SAVE›3200     JSR CLOSE_5›3210     LDA FD_1›3220     STA CD1A+1›3230     LDA FD_2›3240     STA CD2A+1›3250     LDX #$50›3260     LDA #48›3270     STA ICCOM,X›3280     LDA # <CD1A›3290     STA ICBAL,X›3300     LDA # >CD1A›3310     STA ICBAH,X›3320     LDA # <CD1B›3330     STA ICBLL,X›3340     LDA # >CD1B›3350     STA ICBLH,X›3360     JSR CIOV›3370     BPL SCND_ENTRY›3380     JMP CD_ERROR›3390 SCND_ENTRY›3400 ;CHECK FOR BUFFER OVERFLOW›3410     LDA END_TEST1›3420     CMP #$FF›3430     BEQ EOL1›3440     JMP CD_ERROR›3450 EOL1›3460     LDX #$50›3470     LDA #48›3480     STA ICCOM,X›3490     LDA # <CD2A›3500     STA ICBAL,X›3510     LDA # >CD2A›3520     STA ICBAH,X›3530     LDA # <CD2B›3540     STA ICBLL,X›3550     LDA # >CD2B›3560     STA ICBLH,X›3570     JSR CIOV›3580     BPL FIN_CD›3590     JMP CD_ERROR›3600 FIN_CD›3610     LDA END_TEST2›3620     CMP #$FF›3630     BEQ EOL2›3640     JMP CD_ERROR›3650 EOL2›3660     LDY #0›3670     RTS ›3680 CD_ERROR›3690     LDY #1›3700     RTS ›3710 ;-------------------------›3720 DIR_RESTORE›3730     JSR CLOSE_5›3740     LDA FD_1›3750     STA CD2A+1›3760     LDA FD_2›3770     STA CD1A+1›3780     LDX #$50›3790     LDA #44›3800     STA ICCOM,X›3810     LDA # <CD1A›3820     STA ICBAL,X›3830     LDA # >CD1A›3840     STA ICBAH,X›3850     JSR CIOV›3860     BPL SCND_RST›3870     JMP RST_ERR›3880 SCND_RST›3890     LDX #$50›3900     LDA #44›3910     STA ICCOM,X›3920     LDA # <CD2A›3930     STA ICBAL,X›3940     LDA # >CD2A›3950     STA ICBAH,X›3960     JSR CIOV›3970     BPL END_RST›3980     JMP RST_ERR›3990 END_RST›4000     RTS ›4010 ;›4020 ;----------------------------›4030 CLOSE_5›4040     LDX #$50›4050     LDA #$0C›4060     STA ICCOM,X›4070     JSR CIOV›4080     RTS ›4090 ;›4100 ;-------------------------------›4110 ;›4120 ;ERROR TRAPS›4130 ;›4140 ERROR1›4150     LDA # >MESSG1A›4160     LDY # <MESSG1A›4170     JSR PRINT›4180     LDA # >MESSG1B›4190     LDY # <MESSG1B›4200     JSR PRINT›4210     LDA # >MESSG1C›4220     LDY # <MESSG1C›4230     JSR PRINT›4240     LDA # >MESSG1D›4250     LDY # <MESSG1D›4260     JSR PRINT›4270     LDA # >MESSG1E›4280     LDY # <MESSG1E›4290     JSR PRINT›4300     LDA # >MESSG1F›4310     LDY # <MESSG1F›4320     JSR PRINT›4330     LDA # >MESSG1G›4340     LDY # <MESSG1G›4350     JSR PRINT›4360     LDA # >MESSG1I›4370     LDY # <MESSG1I›4380     JSR PRINT›4390     LDA # >MESSG1J›4400     LDY # <MESSG1J›4410     JSR PRINT›4420     LDA # >MESSG1M›4430     LDY # <MESSG1M›4440     JSR PRINT›4450     LDA # >MESSG1N›4460     LDY # <MESSG1N›4470     JSR PRINT›4480     LDA # >MESSG1O›4490     LDY # <MESSG1O›4500     JMP PRINT›4510 ;›4520 ERROR2›4530     LDX OLD_STACK_PTR›4540     TXS ›4550     LDA #MESSG2/256›4560     LDY #MESSG2&255›4570     JMP PRINT›4580 ;›4590 ERROR3›4600     LDA # >MESSG3›4610     LDY # <MESSG3›4620     JMP PRINT›4630 ;›4640 ERROR4›4650     LDA # >MESSG6›4660     LDY # <MESSG6›4670     JSR PRINT›4680     JMP ERROR1›4690 ;›4700 DOSERR›4710     LDA # >MESSG4›4720     LDY # <MESSG4›4730     JMP PRINT›4740 ;›4750 RST_ERR›4760     LDX OLD_STACK_PTR›4770     TXS ›4780     LDA # >MESSG7›4790     LDY # <MESSG7›4800     JMP PRINT›4810 ;›4820 ;SCREEN PRINT SRT *********›4830 ;›4840 PRINT›4850     LDX #0›4860     STA ICBAH,X›4870     TYA ›4880     STA ICBAL,X›4890     LDA #$09›4900     STA ICCOM,X›4910     LDA #$80›4920     STA ICBLL,X›4930     STA ICBLH,X›4940     JSR CIOV›4950     RTS ›4960 ;›4970 ;DATA BUFFS 'N STUFF.›4980 ;›4990 OLD_STACK_PTR›5000     .BYTE $00›5010 ;›5020 CALC_TEST›5030     .BYTE $00›5040 ;›5050 SOURCE›5060     .BYTE $00›5070 ;›5080 DEST›5090     .BYTE $00›5100 ;›5110 OFSET1›5120     .BYTE $00›5130 ;›5140 OFSET2›5150     .BYTE $00›5160 ;›5170 SAVFLAG›5180     .BYTE $00›5190 ;›5200 FD_1›5210     .BYTE $00›5220 ;›5230 FD_2›5240     .BYTE $00›5250 ;›5260 BUFF1A›5270     .BYTE $00,$00,$00,$00,$00,$00›5280     .BYTE $00,$00›5290 BUFF1B›5300     .BYTE $00,$00,$00,$00,$00,$00›5310     .BYTE $00,$00›5320 B_1CLO›5330     .BYTE $00›5340 B_1CHI›5350     .BYTE $00›5360 ;›5370 BUFF2A›5380     .BYTE $00,$00,$00,$00,$00,$00›5390     .BYTE $00,$00›5400 BUFF2B›5410     .BYTE $00,$00,$00,$00,$00,$00›5420     .BYTE $00,$00›5430 B_2CLO›5440     .BYTE $00›5450 B_2CHI›5460     .BYTE $00›5470 ;›5480 IDENTITY›5490     .BYTE "written/revised by Ed Bachman 1986/1989. 417 Hanover St."›5500     .BYTE " Bethlehem Pa. 18018 - 215-868-6478 ** GEnie Id. E.Bachman **"›5510 ;›5520 MESSG1A›5530     .BYTE " DSWAP a program to change"›5540     .BYTE $9B›5550 MESSG1B›5560     .BYTE "drive assigns on the MIO"›5570     .BYTE $9B›5580 MESSG1C›5590     .BYTE $9B›5600 MESSG1D›5610     .BYTE " syntax is as follows..."›5620     .BYTE $9B›5630 MESSG1E›5640     .BYTE "DSWAP /xy[S]"›5650     .BYTE $9B›5660 MESSG1F›5670     .BYTE "  x and y being the numbers of the"›5680     .BYTE $9B›5690 MESSG1G›5700     .BYTE "drives to be swapped."›5710     .BYTE $9B›5720 MESSG1I›5730     .BYTE "[S]=save current working directory"›5740     .BYTE $9B›5750 MESSG1J›5760     .BYTE "on both drives. Optional."›5770     .BYTE $9B›5780 MESSG1M›5790     .BYTE "looks like......"›5800     .BYTE $9B›5810 MESSG1N›5820     .BYTE "DSWAP /23Ó"›5830     .BYTE $9B›5840 MESSG1O›5850     .BYTE "optional param in inverse."›5860     .BYTE $9B›5870 ;›5880 MESSG2›5890     .BYTE " ERROR invalid drive #."›5900     .BYTE $FD,$9B›5910 ;›5920 MESSG3›5930     .BYTE " Can't swap the same drive."›5940     .BYTE $FD,$9B›5950 ;›5960 INTRO1›5970     .BYTE "DSWAP v5.1  by Ed Bachman 1989"›5980     .BYTE $9B›5990 ;›6000 INTRO2›6010     .BYTE " from the L.V.A.U.G."›6020     .BYTE $9B›6030 ;›6040 MESSG4›6050     .BYTE "ERROR! not 3.2 dos or higher."›6060     .BYTE $FD,$9B›6070 ;›6080 MESSG5›6090     .BYTE "current directories restored."›6100     .BYTE $9B›6110 ;›6120 MESSG6›6130     .BYTE "ERROR! invalid command syntax!"›6140     .BYTE $FD,$9B›6150 ;›6160 MESSG7›6170     .BYTE "ERROR while restoring directories"›6180     .BYTE $FD,$9B›6190 ;›6200 MESSG9›6210     .BYTE " operation completed."›6220     .BYTE $9B›6230 ;›6240 ;THESE BUFFERS MUST BE AT THE END OF THE PROGRAM›6250 ;›6260 CD1A›6270     .BYTE "D0:"›6280 CD1B›6290     .BYTE $9B›6300     .DS 255›6310 END_TEST1›6320     .BYTE $FF›6330 EMPTY_SPACE›6340     .DS 16›6350 CD2A›6360     .BYTE "D0:"›6370 CD2B›6380     .BYTE $9B›6390     .DS 255›6400 END_TEST2›6410     .BYTE $FF›6420     .END ›6430 ;-----------------------------›6440 ;this program is placed into the public domain by it's author, and may›6450 ;be freely distrubuted, providing the authors name and that of the›6460 ;L.V.A.U.G. the Lehigh Valley Atari Users Group,and this text remain intact within›6470 ;the program,source code, and documentation. Revisions/changes are›6480 ;welcome however the author requests any modified versions be made›6490 ;available with the source code. and modifications from the original›6500 ;program be noted as such.›6510 ;*****************************›