10 ;SAVE#D3:ARC:UNARC2.M65
20 ;
30 EOUT  STY PRINTEMP
40       STX PRINTEMP+1
50       JSR EOUTCH
60       LDY PRINTEMP
70       LDX PRINTEMP+1
80       RTS 
90 ;
0100 ERETURN LDA #$9B
0110 ;
0120 ;
0130 EOUTCH PHA 
0140     JSR EOUTCH2
0150     PLA 
0160     RTS 
0170 ;
0180 EOUTCH2 TAY 
0190 EMD1 LDA #0
0200     PHA 
0210 EMD2 LDA #0
0220     PHA 
0230     LDX #0
0240     TYA 
0250     RTS 
0260 ;
0270 KGETCH JSR KGET2
0280     CPY #128
0290     BCS KGETCH
0300     RTS 
0310 ;
0320 KGET2 LDX #$30
0330     LDA #7
0340     STA $0342,X
0350     LDA #0
0360     STA $0348,X
0370     STA $0349,X
0380     JMP $E456
0390 ;
0400 PRINT STX $FE
0410     STY $FF
0420 PR1 LDY #0
0430     LDA ($FE),Y
0440     BEQ PR2
0450 PR3 JSR EOUTCH
0460     CPY #128
0470     BCS PR3
0480     INC $FE
0490     BNE PR1
0500     INC $FF
0510     BNE PR1
0520 PR2 RTS 
0530 ;
0540 CLOSE0 LDX #0
0550     .BYTE $2C
0560 CLOSE1 LDX #$10
0570     .BYTE $2C
0580 CLOSE2 LDX #$20
0590     .BYTE $2C
0600 CLOSE3 LDX #$30
0610     LDA #$0C
0620     STA $0342,X
0630     JMP $E456
0640 ;
0650 ERRORTRAP CPY #128
0660     BCS ERT1
0670     RTS 
0680 ERT1 STY $D4
0690     LDA #0
0700     STA $D5
0710     STX OFFSET
0720     JSR SCREENON
0730     LDX OFFSET
0740     CPX #$20    ;WRITE ERR?
0750     BEQ ERT11
0760     LDX #DISKER&255
0770     LDY #DISKER/256
0780     BNE ERT12
0790 ERT11 LDX #DISKERW&255
0800     LDY #DISKERW/256
0810 ERT12 JSR PRINT
0820     JSR PRTNUM
0830     PLA 
0840     PLA 
0850 ERT2 JSR CLOSE1
0860     LDA $0360
0870     CMP #$FF
0880     BEQ ?F1
0890     JSR DODEST
0900     JSR CLOSE2
0910 ?F1 JSR SCREENON
0920     JSR NOTIME
0930     JSR ERETURN
0940     LDA BATCHFLG
0950     BEQ ERT2Z
0960     JMP DUMPOUT
0970 ERT2Z LDX #PRESR&255
0980     LDY #PRESR/256
0990     JSR PRINT
1000     LDA #$FF
1010     STA 764
1020     JSR KGETCH
1030     JMP MAIN
1040 DISKER .BYTE 155,"Disk Read Error #}",0
1050 DISKERW .BYTE 155,"Disk Write Error #}",0
1060 PRESR .BYTE 155,"Press RETURN to continue...",0
1070 ;
1080 PRTNUM
1090     JSR $D9AA
1100     JSR $D8E6
1110     LDY #0
1120 PNM1
1130     LDA ($F3),Y
1140     PHA 
1150     AND #$7F
1160     JSR EOUT
1170     INY 
1180     PLA 
1190     BPL PNM1
1200     RTS 
1210 ;
1220 GETPACK LDA PACKLEN
1230     BNE GETPAK2
1240     ORA PACKLEN+1
1250     BNE GETPAK3
1260     ORA PACKLEN+2
1270     BNE GETPAK1
1280     SEC 
1290     RTS 
1300 ;(EOF) STATUS
1310 GETPAK1 DEC PACKLEN+2
1320 GETPAK3 DEC PACKLEN+1
1330 GETPAK2 DEC PACKLEN
1340 ;
1350 ;
1360 GET1 LDA SBZLEN
1370     BNE GET1D
1380     ORA SBZLEN+1
1390     BNE GET1A
1400     STX PRZP
1410     JSR DOSOUR
1420     LDX #$10
1430     LDA #7      ;load buffer up
1440     STA $0342,X
1450     LDA SBUFF
1460     STA $0344,X
1470     STA GET1C+1
1480     LDA SBUFF+1
1490     STA $0345,X
1500     STA GET1C+2
1510     LDA SBLEN
1520     STA $0348,X
1530     LDA SBLEN+1
1540     STA $0349,X
1550     JSR $E456
1560     BPL GET1B
1570     CPY #136
1580     BEQ GET1B
1590     JMP ERRORTRAP
1600 GET1B LDA $0348,X
1610     STA SBZLEN
1620     LDA $0349,X
1630     STA SBZLEN+1
1640     LDX PRZP
1650     ORA SBZLEN
1660     BNE GET1A
1670     SEC         ;eof status
1680     RTS 
1690 GET1A LDA SBZLEN
1700     BNE GET1D
1710     DEC SBZLEN+1
1720 GET1D DEC SBZLEN
1730 GET1C LDA $FFFF
1740     LDY PASSLOC
1750     BEQ GET1F   ;PASSWORD
1760     EOR PASSWORD-1,Y ;ENCRYPT
1770     INY 
1780     CPY PASSLEN
1790     BCC GET1G
1800     LDY #1
1810 GET1G STY PASSLOC
1820 GET1F INC GET1C+1
1830     BNE GET1E
1840     INC GET1C+2
1850 GET1E CLC 
1860     RTS 
1870 ;
1880 SETBUFF LDY #1
1890 ?SA1 LDA DBUFF,Y
1900     STA PUT2+1,Y
1910     LDA DBLEN,Y
1920     STA DBZLEN,Y
1930     DEY 
1940     BPL ?SA1
1950     RTS 
1960 ;
1970 PUT2 STA $FFFF  ;store byte
1980     LDY ALFFLG  ;ALF sum?
1990     BEQ PUT2O
2000     CLC 
2010     ADC CRC     ;yes.. add...
2020     STA CRC
2030     BCC PUT2P
2040     INC CRC+1
2050     JMP PUT2P
2060 PUT2O EOR CRC
2070     TAY         ;do ARC CRC
2080     LDA CRCLO,Y
2090     EOR CRC+1
2100     STA CRC
2110     LDA CRCHI,Y
2120     STA CRC+1
2130 PUT2P INC PUT2+1
2140     BNE PUT2A
2150     INC PUT2+2
2160 PUT2A LDA DBZLEN
2170     BNE PUT2B
2180     DEC DBZLEN+1
2190 PUT2B DEC DBZLEN
2200     BNE PUT2C
2210     LDA DBZLEN+1
2220     BEQ PUT2D
2230 ;
2240 PUT2C LDA FILLEN ;SEE IF
2250     BNE PUT2C1  ;WE HAVE
2260     LDA FILLEN+1 ;EXPANDED
2270     BNE PUT2C2  ;ALL BYTES...
2280     DEC FILLEN+2
2290 PUT2C2 DEC FILLEN+1
2300 PUT2C1 DEC FILLEN
2310     BNE PUT2C3
2320     LDA FILLEN+1
2330     ORA FILLEN+2
2340     BEQ PUT2C4
2350 PUT2C3 CLC 
2360     RTS 
2370 PUT2C4 JMP FINISHED
2380 ;
2390 PUT2D STX PRZP
2400     JSR SETBUFF
2410     LDA DFNAME
2420     CMP #'N
2430     BEQ ?FIX2
2440     JSR DODEST
2450     JSR DOOPEN
2460     LDA #$0B
2470     LDX #$20
2480     STA $0342,X
2490     LDA DBUFF
2500     STA $0344,X
2510     LDA DBUFF+1
2520     STA $0345,X
2530     LDA DBLEN
2540     STA $0348,X
2550     LDA DBLEN+1
2560     STA $0349,X
2570     JSR $E456
2580     BPL ?FIX2
2590     JMP ERRORTRAP
2600 ?FIX2 LDX PRZP
2610     JMP PUT2C
2620 ;
2630 DOOPEN LDA $0360 ;IOCB 2 OPEN?
2640     CMP #$FF
2650     BEQ DOOP1
2660     RTS 
2670 DOOP1 JSR DOIO
2680     .BYTE $20,3
2690     .WORD DFNAME,0,9
2700     JSR ERRORTRAP
2710     RTS 
2720 ;
2730 FINISHED LDA PUT2+1
2740     CMP DBUFF
2750     BNE FINI1
2760     LDA PUT2+2  ;ANYTHING IN BUFFER?
2770     CMP DBUFF+1
2780     BEQ FIN2
2790 FINI1 LDA DFNAME
2800     CMP #'N
2810     BEQ FIN2    ;NULL
2820     JSR DODEST
2830     JSR DOOPEN
2840     LDA #$0B
2850     LDX #$20
2860     STA $0342,X
2870     LDA DBUFF
2880     STA $0344,X
2890     STA PUT2+1
2900     LDA DBUFF+1
2910     STA $0345,X
2920     STA PUT2+2
2930     SEC 
2940     LDA DBLEN
2950     SBC DBZLEN
2960     STA $0348,X
2970     LDA DBLEN+1
2980     SBC DBZLEN+1
2990     STA $0349,X
3000     JSR $E456
3010     BPL FIN2
3020     JMP ERRORTRAP
3030 FIN2 JSR CLOSE2
3040     PHP 
3050     JSR NOTIME
3060     PLP 
3070     BPL ?FIX3
3080     JMP ERRORTRAP
3090 ?FIX3 LDA DBUFF
3100     STA DBZLEN
3110     LDA DBUFF+1
3120     STA DBZLEN+1
3130     LDA CRC
3140     CMP HEADER+23
3150     BNE FIN2A
3160     LDA CRC+1
3170     CMP HEADER+24
3180     BNE FIN2A
3190 FIN2B SEC       ;INDICATE EOF
3200     RTS 
3210 ;
3220 FIN2A LDX #CRCM&255
3230     LDY #CRCM/256
3240     JSR PRINT
3250     LDA #0
3260     STA SCRON
3270     JMP FIN2B
3280 CRCM .BYTE "Error: File fails CRC check!}",155,0
3290 ;
3300 NOTIME LDA SPARTAF
3310     BEQ NOTM1
3320     LDA TIMEFLG
3330     BEQ NOTM1
3340     LDY #25
3350     LDA #0
3360     STA ($0A),Y
3370 NOTM1 RTS 
3380 ;
3390 ;THE CRC TABLE (LOW BYTES FIRST)
3400 ;
3410 CRCLO
3420     .BYTE $00,$C1,$81,$40,$01,$C0,$80,$41
3430     .BYTE $01,$C0,$80,$41,$00,$C1,$81,$40
3440     .BYTE $01,$C0,$80,$41,$00,$C1,$81,$40
3450     .BYTE $00,$C1,$81,$40,$01,$C0,$80,$41
3460     .BYTE $01,$C0,$80,$41,$00,$C1,$81,$40
3470     .BYTE $00,$C1,$81,$40,$01,$C0,$80,$41
3480     .BYTE $00,$C1,$81,$40,$01,$C0,$80,$41
3490     .BYTE $01,$C0,$80,$41,$00,$C1,$81,$40
3500     .BYTE $01,$C0,$80,$41,$00,$C1,$81,$40
3510     .BYTE $00,$C1,$81,$40,$01,$C0,$80,$41
3520     .BYTE $00,$C1,$81,$40,$01,$C0,$80,$41
3530     .BYTE $01,$C0,$80,$41,$00,$C1,$81,$40
3540     .BYTE $00,$C1,$81,$40,$01,$C0,$80,$41
3550     .BYTE $01,$C0,$80,$41,$00,$C1,$81,$40
3560     .BYTE $01,$C0,$80,$41,$00,$C1,$81,$40
3570     .BYTE $00,$C1,$81,$40,$01,$C0,$80,$41
3580     .BYTE $01,$C0,$80,$41,$00,$C1,$81,$40
3590     .BYTE $00,$C1,$81,$40,$01,$C0,$80,$41
3600     .BYTE $00,$C1,$81,$40,$01,$C0,$80,$41
3610     .BYTE $01,$C0,$80,$41,$00,$C1,$81,$40
3620     .BYTE $00,$C1,$81,$40,$01,$C0,$80,$41
3630     .BYTE $01,$C0,$80,$41,$00,$C1,$81,$40
3640     .BYTE $01,$C0,$80,$41,$00,$C1,$81,$40
3650     .BYTE $00,$C1,$81,$40,$01,$C0,$80,$41
3660     .BYTE $00,$C1,$81,$40,$01,$C0,$80,$41
3670     .BYTE $01,$C0,$80,$41,$00,$C1,$81,$40
3680     .BYTE $01,$C0,$80,$41,$00,$C1,$81,$40
3690     .BYTE $00,$C1,$81,$40,$01,$C0,$80,$41
3700     .BYTE $01,$C0,$80,$41,$00,$C1,$81,$40
3710     .BYTE $00,$C1,$81,$40,$01,$C0,$80,$41
3720     .BYTE $00,$C1,$81,$40,$01,$C0,$80,$41
3730     .BYTE $01,$C0,$80,$41,$00,$C1,$81,$40
3740 ;
3750 CRCHI
3760     .BYTE $00,$C0,$C1,$01,$C3,$03,$02,$C2
3770     .BYTE $C6,$06,$07,$C7,$05,$C5,$C4,$04
3780     .BYTE $CC,$0C,$0D,$CD,$0F,$CF,$CE,$0E
3790     .BYTE $0A,$CA,$CB,$0B,$C9,$09,$08,$C8
3800     .BYTE $D8,$18,$19,$D9,$1B,$DB,$DA,$1A
3810     .BYTE $1E,$DE,$DF,$1F,$DD,$1D,$1C,$DC
3820     .BYTE $14,$D4,$D5,$15,$D7,$17,$16,$D6
3830     .BYTE $D2,$12,$13,$D3,$11,$D1,$D0,$10
3840     .BYTE $F0,$30,$31,$F1,$33,$F3,$F2,$32
3850     .BYTE $36,$F6,$F7,$37,$F5,$35,$34,$F4
3860     .BYTE $3C,$FC,$FD,$3D,$FF,$3F,$3E,$FE
3870     .BYTE $FA,$3A,$3B,$FB,$39,$F9,$F8,$38
3880     .BYTE $28,$E8,$E9,$29,$EB,$2B,$2A,$EA
3890     .BYTE $EE,$2E,$2F,$EF,$2D,$ED,$EC,$2C
3900     .BYTE $E4,$24,$25,$E5,$27,$E7,$E6,$26
3910     .BYTE $22,$E2,$E3,$23,$E1,$21,$20,$E0
3920     .BYTE $A0,$60,$61,$A1,$63,$A3,$A2,$62
3930     .BYTE $66,$A6,$A7,$67,$A5,$65,$64,$A4
3940     .BYTE $6C,$AC,$AD,$6D,$AF,$6F,$6E,$AE
3950     .BYTE $AA,$6A,$6B,$AB,$69,$A9,$A8,$68
3960     .BYTE $78,$B8,$B9,$79,$BB,$7B,$7A,$BA
3970     .BYTE $BE,$7E,$7F,$BF,$7D,$BD,$BC,$7C
3980     .BYTE $B4,$74,$75,$B5,$77,$B7,$B6,$76
3990     .BYTE $72,$B2,$B3,$73,$B1,$71,$70,$B0
4000     .BYTE $50,$90,$91,$51,$93,$53,$52,$92
4010     .BYTE $96,$56,$57,$97,$55,$95,$94,$54
4020     .BYTE $9C,$5C,$5D,$9D,$5F,$9F,$9E,$5E
4030     .BYTE $5A,$9A,$9B,$5B,$99,$59,$58,$98
4040     .BYTE $88,$48,$49,$89,$4B,$8B,$8A,$4A
4050     .BYTE $4E,$8E,$8F,$4F,$8D,$4D,$4C,$8C
4060     .BYTE $44,$84,$85,$45,$87,$47,$46,$86
4070     .BYTE $82,$42,$43,$83,$41,$81,$80,$40
4080 ;
4090 ;
4100 TITLE .BYTE 125
4110     .BYTE 155,"Enter complete source filename:",155,0
4120 DSTPN .BYTE 155,"Destination Drive # or Path [&mask]:",155,0
4130 INVP .BYTE 155,"Invalid Pathname!",155
4140     .BYTE "Examples: 1, D2:*.BAS, D2:DIR>, or P:",155,0
4150 SDSECM .BYTE "S/D Sectors:",0
4160 SDMSG2 .BYTE "  Bytes Saved:",0
4170 UNARM .BYTE 155,"[1-9] Dirs, [P]athname.  Extract?",0
4180 ;
4190 PAKMSG .BYTE "Un-StoringUn-AlfingTEND .BYTE "----------------------------------"
4250     .BYTE 155,"Total Sector Length (SD) = ",0
4260 ;
4270 FP65536 .BYTE $42,$06,$55,$36,0,0
4280 FP125 .BYTE $41,1,$25,0,0,0
4290 FP124 .BYTE $41,1,$24,0,0,0
4300 YESNO .BYTE "YesNo!"
4310 INSRC .BYTE 155,"Insert SOURCE disk, press RETURN",155,0
4320 INDES .BYTE 155,"Insert DESTINATION Disk, press RETURN",155,0
4330 RECM .BYTE 155,"Disk Error Recovery Menu:",155
4340     .BYTE "  [P] Change Dest. Path/Drive #",155
4350     .BYTE "  [1-9] Directories",155
4360     .BYTE "  [ESC] Exit to main menu",155
4370     .BYTE "Or press RETURN to try again:",0
4380 OVERM .BYTE 155,"File already exists - Replace?",0
4390 CHGPARM .BYTE 155,155,"Use , RETURN - toggle, ESC - exit",155,0
4400 ;
4410 TITLEM .BYTE $20,$7D
4420     .BYTE "�����������������������������������Ŀ",155
4430     .BYTE "�Screen Off:Yes  Extract w/Query:No!�",155
4440     .BYTE "�Disk Swaps:No!  Time/Date Stamp:No!�",155
4450     .BYTE "�Over-Write:No!  Password Encrpt:No!�",155
4460     .BYTE "