home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
8bitfiles.net/archives
/
archives.tar
/
archives
/
genie-commodore-file-library
/
C64Toolkit
/
FILECPY.ARC
/
1541
/
SFD.SRC
(
.txt
)
Wrap
Commodore BASIC
|
2019-04-13
|
3KB
|
164 lines
10 *= $7000
20 .M
30 ;
40 ;STANDARD DRIVE COMMANDS
50 ;
60 OPEN = $FFC0
70 CLOSE = $FFC3
80 INCHN = $FFC6
90 OUTCHN = $FFC9
100 CLRCHN = $FFCC
110 SETNM = $FFBD
120 SETLFS = $FFBA
130 GET = $FFE4
140 PRINT = $FFD2
150 BUFFER = $8000;STORE 256 BYTES OF FILE
160 ;
170 ;DIRECT ACCESS DRIVE COMMANDS
180 ;
190 LIS = $FFB1
200 LISEC = $FF93
210 UNLIS = $FFAE
220 OUT = $FFA8
230 ;
240 LDA #$93;CLEAR SCREEN
250 JSR PRINT;PRINT FILE MESSAGE
260 LDY #$00
270 MES LDA MESS,Y
280 CMP #$00;DELIMITER END OF TEXT
290 BEQ STREAD
300 JSR PRINT
310 INY
320 JMP MES
330 ;
340 STREAD LDY #$00
350 STY Y;TEMPORARY Y SAVE $FFE4 USES Y AND Y IS LOST
360 STRD JSR GET;ACCEPT KEYSTROKES
370 BEQ STRD
380 CMP #$0D;RETURN END OF FILE NAME
390 BEQ READ
400 LDY Y
410 STA BUFF1,Y;BUFFER FILE NAME BYTE
420 JSR PRINT;ECHO TO SCREEN
430 INC Y
440 JMP STRD
450 ;
460 READ LDY Y;# OF BYTES IN FILENAME
470 STY FCOUNT
480 LDX #$00
490 LDY Y
500 RDLP LDA PRG,X;ADD ,P,W TO FILENAME
510 STA BUFF1,Y
520 INY
530 INX
540 CPX #$04
550 BNE RDLP
560 ;
570 ;OPEN DEVICE 8 FOR READ
580 ;
590 LDA #$03;FILE #
600 LDX #$08;DEVICE #
610 LDY #$03;SECONDARY ADDRESS
620 JSR SETLFS;SAME AS OPEN3,8,3
630 LDA FCOUNT;# OF BYTES IN FILENAME
640 LDX #<BUFF1;LO BYTE ADDRESS FOR FILENAME
650 LDY #>BUFF1;HI BYTE " " " "
660 JSR SETNM
670 JSR OPEN
680 ;
690 ;CLRCHN (CLEAR CHANNEL) ALLOWS ONE DEVICE
700 ;TO BE PUT ON HOLD, AND ANOTHER DEVICE
710 ;TO BE ACTIVATED.
720 ;
730 JSR CLRCHN
740 ;
750 ;OPEN DEVICE 9 FOR WRITE
760 ;
770 LDA #$07
780 LDX #$09
790 LDY #$07
800 JSR SETLFS
810 LDA FCOUNT
820 CLC
830 ADC #$04;",P,W" = 4 BYTES
840 STA FCOUNT
850 LDX #<BUFF1
860 LDY #>BUFF1
870 JSR SETNM
880 JSR OPEN
890 JSR CLRCHN
900 ;
910 ;READ AND BUFFER 256 BYTES
920 ;
930 ST LDY #$00
940 STY Y
950 LDX #$03
960 JSR INCHN;OPEN CHANNEL TO READ
970 LP JSR GET;GET 1 BYTE
980 LDY Y
990 STA BUFFER,Y
1000 LDA $90;SERIAL STATUS, (ERROR WORD)
1010 BNE END;0 = OK
1020 INC Y
1030 LDY Y
1040 CPY #$FE
1050 BNE LP
1060 STY Y;USED FOR BLOCK LESS THAN 256 BYTES EOF SITUATION
1070 JSR CLRCHN;SHUT DOWN READ CHANNEL
1080 ;
1090 ;READ BYTES BUFFERED AND WRITE TO DEVICE 9
1100 ;
1110 ST1 LDX #$07
1120 JSR OUTCHN;OPEN WRITE CHANNEL
1130 LDY #$00
1140 LP1 LDA BUFFER,Y
1150 JSR PRINT;PRINT TO DEVICE 9
1160 LDA $90
1170 BNE END
1180 INY
1190 CPY Y;# OF BYTES READ
1200 BNE LP1
1210 JSR CLRCHN;SHUT DOWN WRITE CHANNEL
1220 LDA EFLG;= 1 WHEN END OF FILE SENT FROM DEVICE 8
1230 BNE END1
1240 JMP ST;GET ANOTHER BLOCK OF FILE
1250 ;
1260 ;SET EFLG UP (1) EOF SENT
1270 ;
1280 END LDA #$1
1290 STA EFLG
1300 INC Y;ADJUST FOR LAST CHARACTER BUFFERED
1310 JMP ST1;WRITE LAST BLOCK READ TO DEVICE 9
1320 ;
1330 ;CLOSE DOWN BOTH DEVICES
1340 ;
1350 END1 JSR CLRCHN
1360 LDA #$03
1370 JSR CLOSE
1380 ;
1390 LDA #$07
1400 JSR CLOSE
1410 LDA #$00;SET EFLAG FOR NEXT READ
1420 STA EFLG
1430 ;
1440 ;SEND I0, (INITIALIZE) TO SFD
1450 ;
1460 LDA #$09
1470 JSR LIS
1480 LDA #$FF
1490 JSR LISEC
1500 LDA #"I
1510 JSR OUT
1520 LDA #"0
1530 JSR OUT
1540 LDA #$09
1550 JSR UNLIS
1560 BRK;BRK COMMAND TO GET BACK TO M/L MONITOR
1570 ;
1580 Y .B 0
1590 EFLG .B 0
1600 FCOUNT .B 0
1610 MESS .B "ENTER NAME OF FILE:.B 13 13 0
1620 PRG .B ",P,W
1630 BUFF1 .B 0