Classic Computer Magazine Archive PROGRAM LISTING: 85-09/COPY130.M65


02 ; COPY130
04 ; BY ERNIE NEGUS
06 ; (c) 1985, ANTIC PUBLISHING
10       *=  $2600   ;ROOM FOR DOS XL
20       JMP START
30 DBUFHI =  $0305   ;O.S. EQUATES
40 DBUFLO =  $0304   ;FOR OS I/O AND
50 DAUX2 =   $030B   ;DIRECT DISK I/O
60 DAUX1 =   $030A
70 DCOMND =  $0302
80 DUNIT =   $0301
90 ICCOM =   $0342
0100 ICBADR = $0344
0110 ICBLEN = $0348
0120 ICAUX1 = $034A
0130 ICAUX2 = $034B
0140 CARTR = $A000   ;MESSAGE AREA
0150 DES .BYTE "Destination #"
0160 FMT .BYTE "Format Destination ?"
0170 VER .BYTE "Verify Writes ?"
0180 STE .BYTE "Continue on Errors ?"
0190 RDG .BYTE $9B,"Reading..."
0200 WRT .BYTE $9B,"Writing..."
0210 IND .BYTE $9B,"Insert DESTINATION disk-Press �����"
0220 INS .BYTE "Insert SOURCE in Drive 1-Type �����"
0230 ANC .BYTE $9B,$FD,"Another copy ?"
0240 FRM .BYTE $9B,"Formatting..."
0250 REM .BYTE "Remove Cartridges First!",$9B
0260 O130 .BYTE "Program only runs on a 130 XE!!",$9B
0270 TIT1 .BYTE $1D,"     ��������Ҡ�����Ҡ�����Š��",$1D,$9B
0280 TIT2 .BYTE "           By Ernie Negus",$1D,$1D,$1D,$9B
0290 KEY .BYTE "K:"
0300 SCR .BYTE "S:"
0310 SECNT .BYTE 0   ;VARIABLES
0320 DEST .BYTE 0    ;USED BY PROGRAM
0330 FRMT .BYTE 0
0340 SOUR .BYTE 0
0350 DCOM .BYTE 0
0360 DTEM .BYTE 0
0370 SAVA .BYTE 0
0380 VERI .BYTE 0
0390 SPEC .BYTE 0
0400 SAVSPE .BYTE 0
0410 CERR .BYTE 0
0420 DRIVE .BYTE 0
0430 BPUT LDA #$26   ;OUTPUT TEXT
0440 BPUU STA ICBADR+1 ;SUBROUTINE
0450     LDA #0
0460     STA ICBLEN+1
0470     STX ICBLEN
0480     STY ICBADR
0490     LDX #0
0500     LDA #$0B
0510     STA ICCOM
0520     JSR $E456
0530     RTS 
0540 BGET LDX #$10   ;INPUT BYTE FROM
0550     LDA #7      ;KEYBOARD SUB.
0560     STA ICCOM,X
0570     LDA #0
0580     STA ICBLEN,X
0590     STA ICBLEN+1,X
0600     JSR $E456
0610     STA $0600
0620     CMP #$1B    ;ESCAPE RERUNS
0630     BNE RET2    ;THE PROGRAM.
0640     PLA 
0650     PLA 
0660     JMP START
0670 RET2 RTS 
0680 OPEN LDX #16    ;OPEN CHANNELS
0690     LDA #3      ;1 FOR KEYBOARD
0700     STA ICCOM,X ;6 FOR SCREEN.
0710     LDA # <KEY
0720     STA ICBADR,X
0730     LDA # >KEY
0740     STA ICBADR+1,X
0750     LDA #4
0760     STA ICAUX1,X
0770     JSR $E456
0780     LDX #$60
0790     LDA #3
0800     STA ICCOM,X
0810     LDA # <SCR
0820     STA ICBADR,X
0830     LDA # >SCR
0840     STA ICBADR+1,X
0850     LDA #12
0860     STA ICAUX1,X
0870     LDA #0
0880     STA ICAUX2,X
0890     JSR $E456
0900     RTS 
0910 CLOSE LDX #$10  ;INSURES THOSE
0920     LDA #12     ;FILES CLOSED.
0930     STA ICCOM,X
0940     JSR $E456
0950     LDX #$60
0960     LDA #12
0970     STA ICCOM,X
0980     JSR $E456
0990     RTS 
1000 START LDA CARTR ;THIS IS A
1010     INC CARTR   ;CARTRIDGE TEST
1020     CMP CARTR
1030     BNE NOCARTS
1040     LDX #25
1050     LDY # <REM
1060     JSR BPUT
1070     RTS 
1080 NOCARTS LDA #$E3 ;TEST FOR 130XE
1090     STA 54017   ;BY SEEING IF
1100     STA $4000   ;THE BANK SWITCH
1110     LDA #255    ;WORKS.
1120     STA 54017
1130     LDA $4000
1140     CMP #$E3
1150     BNE ITSA130
1160     LDA #255
1170     STA 54017
1180     LDX #32
1190     LDY # <O130
1200     JSR BPUT
1210     RTS         ;RETURN TO DOS
1220 ITSA130 LDA #48
1230     STA 106     ;FORCE SCREEN
1240     JSR CLOSE   ;RAM BELOW $4000
1250     JSR OPEN
1260     JMP BEGIN
1270 PUTO LDA #$10   ;DRAWS THE
1280     STA 11546   ;DISPLAY WINDOW
1290     STA 11547   ;ON THE SCREEN.
1300     STA 11548
1310     LDA #128
1320     STA 11543
1330     STA 11545
1340     STA 11549
1350     STA 11551
1360     LDX #0
1370     STX 11550
1380 LOOX LDA #$55   ;DRAW BORDER.
1390     STA 11503,X
1400     LDA #$D5
1410     STA 11583,X
1420     INX 
1430     CPX #9
1440     BNE LOOX
1450     RTS 
1460 ECHO STA $0600  ;ECHO KEY TO
1470     LDA #$9B    ;SCREEN. DOES
1480     STA $0601   ;A LINE FEED.
1490     LDX #2
1500     LDY #0
1510     LDA #6
1520     JSR BPUU
1530     RTS 
1540 BEGIN LDX #63   ;HERE IF 130 XE
1550     LDY # <TIT1
1560     LDA # >TIT1
1570     JSR BPUU    ;PRINT TITLE
1580     LDA #0
1590     STA SPEC
1600     LDA #148
1610     STA 710
1620     STA 712
1630     LDA #12
1640     STA 709
1650     LDX #13
1660     LDY # <DES
1670     JSR BPUT
1680 LAB2 JSR BGET   ;GET DEST. #
1690     CMP #'1     ;INSURE PROPER
1700     BCC LAB2    ;RANGE...
1710     CMP #'D     ;DUAL DRIVE
1720     BEQ DUAL
1730     CMP #'T     ;TRIPLE DRIVE
1740     BEQ TRIP
1750     CMP #'Q
1760     BEQ QUAD    ;QUAD DRIVE
1770     CMP #'9     ;UPPER RANGE.
1780     BCS LAB2
1790     JMP SING
1800 QUAD LDA #4     ;USED FOR
1810     BNE MULT    ;LOOPING WHEN
1820 TRIP LDA #3     ;MULTI-DEST.
1830     BNE MULT    ;ENABLED.
1840 DUAL LDA #2
1850 MULT STA SPEC
1860     STA SAVSPE  ;SAVE FOR
1870     LDA #'1     ;ANOTHER COPY.
1880 SING STA DEST   ;USE DRIVE 1
1890     STA DRIVE   ;IF MULTI-DEST.
1900     JSR ECHO
1910     LDA DEST
1920     SEC 
1930     SBC #'0
1940     STA DEST
1950     LDX #20
1960     LDY # <FMT
1970     JSR BPUT
1980     JSR BGET    ;FORMAT OR NOT?
1990     JSR ECHO
2000     LDA $0600
2010     STA FRMT    ;SAVE ANSWER.
2020     LDX #15
2030     LDY # <VER
2040     JSR BPUT
2050     JSR BGET    ;VERIFY OR NOT?
2060     JSR ECHO
2070     LDA $0600
2080     STA VERI    ;SAVE ANSWER.
2090     LDA #255
2100     STA 54017
2110     LDX #20
2120     LDY # <STE  ;STOP ON
2130     JSR BPUT    ;ERROR?
2140     JSR BGET
2150     JSR ECHO
2160     LDA $0600
2170     STA CERR    ;SAVE ANSWER
2180     LDX #36
2190     LDY # <INS
2200     JSR BPUT
2210     JSR BGET
2220     LDA $0600   ;IF 'N' INSTEAD
2230     CMP #'N     ;OF RETURN, SKIP
2240     BEQ BLOOP   ;THE READ.
2250     LDX #11
2260     LDY # <RDG
2270     JSR BPUT
2280     JSR PUTO    ;PUT DISPLAY
2290     LDA #1      ;WINDOW UP AND
2300     STA DTEM    ;READ DATA OFF
2310     LDA #0      ;OF SOURCE.
2320     STA DAUX1
2330     STA DAUX2
2340     LDA #'R     ;'R' FOR READ
2350     STA DCOM
2360     LDA #255
2370     STA SECNT   ;READ IN 255
2380     JSR AVOID   ;SECTORS.
2390     LDA #$E3    ;ENABLE BANK 1
2400     STA 54017
2410     JSR DODISK
2420     LDA #$E7    ;ENABLE BANK 2
2430     STA 54017
2440     JSR DODISK
2450     LDA #$EB    ;ENABLE BANK 3
2460     STA 54017
2470     JSR DODISK
2480     LDA #$EF    ;ENABLE BANK 4
2490     STA 54017
2500     LDA #84     ;THIS TIME DO
2510     STA SECNT   ;NOT USE DEFAULT
2520     JSR AVOID   ;SECTOR COUNT.
2530 BLOOP LDA #255  ;THIS IS THE
2540     STA 54017   ;WRITE LOOP.
2550     LDA DEST
2560     CMP #1
2570     BNE AUTO
2580     LDX #37     ;INSERT PROMPT.
2590     LDY # <IND
2600     JSR BPUT
2610     JSR BGET
2620 AUTO LDA FRMT
2630     CMP #'Y     ;DID THEY WANT
2640     BNE SKYP    ;TO FORMAT?
2650     LDX #14
2660     LDY # <FRM
2670     JSR BPUT
2680     LDA #'!
2690     STA DCOMND  ;SET UP FORMAT
2700     LDA DEST
2710     STA DUNIT
2720     JSR PUTO
2730     JSR GONE    ;DISPLAY DRIVE #
2740     LDA #0
2750     STA DBUFLO
2760     LDA #4
2770     STA DBUFHI
2780     JSR $E453
2790     LDY #173
2800     LDA $0308
2810     BEQ SKYP
2820     LDX #'N
2830     STX CERR
2840     JSR ERRO    ;REPORT ERRORS
2850 SKYP LDX #11
2860     LDY # <WRT
2870     JSR BPUT
2880     JSR PUTO    ;DRAW WINDOW.
2890     LDA DEST    ;BEGIN WRITING.
2900     STA DTEM
2910     LDA #0
2920     STA DAUX2
2930     STA DAUX1
2940     LDA #'W     ;WRITE VERIFY?
2950     STA DCOM
2960     LDA VERI    ;<THE ANSWER.
2970     CMP #'Y
2980     BEQ SKIZZ
2990     LDA #'P     ;OR JUST PUT?
3000     STA DCOM
3010 SKIZZ LDA #255
3020     STA SECNT   ;WRITE OWN RAM.
3030     JSR AVOID   ;255 SECTORS.
3040     LDA #$E3    ;WRITE BANK 1.
3050     STA 54017
3060     JSR DODISK
3070     LDA #$E7    ;WRITE BANK 2
3080     STA 54017
3090     JSR DODISK
3100     LDA #$EB    ;WRITE BANK 3
3110     STA 54017
3120     JSR DODISK
3130     LDA #$EF    ;WRITE BANK 4
3140     STA 54017
3150     LDA #84     ;BUT DON'T USE
3160     STA SECNT   ;DEFAULT THIS
3170     JSR AVOID   ;TIME!
3180     LDA #255
3190     STA 54017   ;DISABLES BANKS
3200     LDA SPEC
3210     BEQ OVER    ;MULTI-DEST?
3220     CMP #1
3230     BEQ OVER    ;IF SO, DONE?
3240     STA DEST
3250     CLC 
3260     ADC #'0     ;DO NEXT DRIVE
3270     STA DRIVE
3280     DEC SPEC
3290     JMP BLOOP   ;UNTIL FINISHED.
3300 OVER LDX #16
3310     LDY # <ANC
3320     JSR BPUT
3330     JSR BGET    ;ANOTHER COPY?
3340     JSR ECHO
3350     LDA $0600
3360     CMP #'Y
3370     BNE QUIT
3380     LDA SPEC    ;YES- RESTORE
3390     BEQ JUMP    ;VALUES IF MULTI
3400     LDA SAVSPE  ;DESTINATION
3410     STA SPEC    ;DRIVES.
3420     LDA #1
3430     STA DEST
3440     LDA #'1
3450     STA DRIVE   ;(FOR FORMAT).
3460 JUMP JMP BLOOP
3470 QUIT JMP START  ;RE-RUN PROGRAM
3480 DODISK LDA #127
3490     STA SECNT   ;THIS SUBROUTINE
3500 AVOID LDA #$3F  ;DOES THE DISK
3510     STA DBUFHI  ;I/O AND KEEPS
3520     LDA #$80    ;TRACK OF THE
3530     STA DBUFLO  ;MEMORY POINTERS
3540 DOSUP LDA DTEM
3550     STA DUNIT
3560     LDA DCOM
3570     STA DCOMND
3580 LOOP CLC 
3590     LDA DAUX1
3600     ADC #1
3610     STA DAUX1
3620     LDA DAUX2
3630     ADC #0
3640     STA DAUX2
3650     CLC 
3660     JSR INCO    ;IT ALSO KEEPS
3670     LDA DBUFLO  ;TRACK OF THE
3680     ADC #$80    ;SECTOR COUNTER.
3690     STA DBUFLO
3700     LDA DBUFHI
3710     ADC #0
3720     STA DBUFHI
3730     JSR $E453   ;THE O.S. CALL.
3740     CPY #1
3750     BEQ GDIO    ;IF ERROR FOUND
3760 ERRO JSR RER    ;DECODE IT AND
3770     STX 11550   ;DISPLAY IT IN
3780     LDA CERR
3790     CMP #'Y     ;STOP ON ERROR
3800     BEQ GDIO    ;UNLESS TOLD NOT
3810     PLA         ;TO.
3820     PLA 
3830     JMP OVER
3840 GDIO DEC SECNT  ;THE RIGHT PART
3850     BNE LOOP    ;OF THE DISPLAY
3860     RTS         ;WINDOW.
3870 INCO LDX #3
3880 LOCO INC 11545,X
3890     LDA 11545,X ;INCREMENTS THE
3900     CMP #$1A    ;SECTOR COUNTER
3910     BNE GONE    ;IN THE WINDOW.
3920     LDA #$10
3930     STA 11545,X
3940     DEX 
3950     BNE LOCO
3960 GONE LDA DUNIT  ;ALSO DISPLAYS
3970     CLC         ;THE DRIVE
3980     ADC #$10    ;CURRENTLY IN
3990     STA 11544   ;USE.
4000     RTS 
4010 RER LDX #$10    ;DECODE ERRORS
4020     CPY #127    ;NON-IO ERROR
4030     BCC RETURN
4040     INX 
4050     CPY #128    ;BREAK KEY ABORT
4060     BEQ RETURN
4070     INX 
4080     CPY #138    ;DEVICE TIMEOUT
4090     BEQ RETURN
4100     INX 
4110     CPY #139    ;NO ACKNOWLEDGE
4120     BEQ RETURN
4130     INX 
4140     CPY #140    ;SERIAL BUS DATA
4150     BEQ RETURN
4160     CPY #142    ;ERRORS.
4170     BEQ RETURN
4180     CPY #143    ;DITTO
4190     BEQ RETURN
4200     INX 
4210     CPY #144    ;BAD SECTOR/
4220     BEQ RETURN  ;OPEN DOOR.
4230     INX 
4240     CPY #145    ;BAD READ VERIFY
4250     BEQ RETURN
4260     INX 
4270     CPY #163    ;DAMAGED DOS
4280     BEQ RETURN
4290     INX 
4300     CPY #164    ;BAD FILE NUMBER
4310     BEQ RETURN
4320     INX 
4330     CPY #173    ;BAD SECTOR
4340     BEQ RETURN  ;DURING FORMAT.
4350     LDX #$10    ;NON-HANDLED ERROR
4360 RETURN RTS 
4365 ;
4370     *=  $02E0   ;  FOR DOS 2
4380     .WORD START
4390     .END 

Back to previous page