8-Bit Software Online Conversion
:2.$.srlsrc - Listing
10REM > SrlSrc - Fast Srfile`load uti
lity
20REM (c) Petrov Software
30:
40n$="Srl"
50:
60DIM code% 1000
70:
80rom`num=&F4:rom`sel=&FE30:REM ROM s
elect register
90rom`info=&2A1:romtbl=&DF0
100rom`type=&8006
110test`loc=&BFFF
120osptr=&F2
130page`size=&4000
140rom`start=&8000
150ld`addr%=&FFFF0900:REM Master or Co
mpact users could change to &FFFFDD00
170nofroms%=16
180:
190P%=&70
200cmdline=FNz(2)
210ptr1=FNz(2)
220ptr2=FNz(2)
230file`block=FNz(0)
240file`nameptr=FNz(2)
250file`load=FNz(4)
260file`exec=FNz(4)
270file`length=FNz(4):REM not used her
e
280file`attrib=FNz(4):REM not used her
e
290:
300osbyte=&FFF4:osfile=&FFDD:osargs=&F
FDA
310gsinit=&FFC2:gsread=&FFC5
320:
330FOR pass%=4 TO 6 STEP 2:P%=ld`addr%
:O%=code%
340[OPT pass%
350.get`name
360 STA loc2+1 ½ A=0 - modify b
ranch instruction
370 TAX
380.get`name`loop
390 JSR gsread
400 BCC get`name1
410 LDA #13 ½ terminator for
filename
420.get`name1
430 STA filename,X
440 INX
450 BCC get`name`loop
460 STY loc1+1
470 RTS
480
490 .no`room
500 OPT FNerr(&E0,"No free RAM banks")
510
520.search`free`slot
530 DEX
540 BMI no`room
550 LDA rom`info,X
560 BNE search`free`slot
570 STX rom`num
580 STX rom`sel
590 LDA test`loc
600 EOR #&FF
610 STA test`loc
620 EOR test`loc
630.sear`f`slot
640 BNE search`free`slot
650 JSR get`name
660 LDA #&83
670 JSR osbyte
680 STX file`load
690 STY file`load+1
700 STX ptr1
710 STY ptr1+1
720 LDY #&FF
730 STY file`load+2
740 STY file`load+3
750 INY ½ Y
= 0
760 STY file`exec
770 STY ptr2
780 LDA #FNh(rom`start)
790 STA ptr2+1
800 LDX #FNh(page`size)-1
810 .copy`loop
820 LDA (ptr1),Y
830 STA (ptr2),Y
840 INY
850 BNE copy`loop
860 INC ptr1+1
870 INC ptr2+1
880 DEX
890 BPL copy`loop
900 TXA ½ A=&
FF - load file
910 LDX #FNl(file`block)
920 LDY #FNh(file`block)
930 JSR osfile
940 LDX #FNh(page`size)
941]
942IF FNh(file`block) [OPT pass%:LDY #
0:]
943[OPT pass%
960 .swap
970 DEC ptr1+1
980 DEC ptr2+1
990 .swap256
1000 LDA (ptr1),Y
1010 PHA
1020 LDA (ptr2),Y
1030 STA (ptr1),Y
1040 PLA
1050 STA (ptr2),Y
1060 INY
1070 BNE swap256
1080 DEX
1090 BNE swap
1100 TXA
1110 LDX rom`num
1120 STA romtbl,X
1130 LDA rom`type
1140 STA rom`info,X
1150.begin
1160 LDA cmdline
1170 LDY cmdline+1
1180 STA osptr
1190 STY osptr+1
1200.loc1
1210 LDY #0 ½ Y
=?(loc1+1)
1220 CLC
1230 JSR gsinit
1240 BNE sear`f`slot ½ s
earch`free`slot gives 'Out of range'
1250.loc2
1260 BEQ synterr ½ ?
(loc2+1) - branch offset
1270 PLA
1280 STA rom`num
1290 STA rom`sel
1300 RTS
1310
1320.start
1330 LDA rom`num
1340 PHA
1350 LDA #FNl(filename)
1360 STA file`nameptr
1370 LDA #FNh(filename)
1380 STA file`nameptr+1
1390 LDA #1
1400 LDX #cmdline
1410 LDY #0
1420 JSR osargs
1470 LDX #nofroms%
1480 BNE begin ½ BRA
1490
1500.filename
1510.synterr
1520 OPT FNerr(&E0,"Syntax: Srl <rom>
.. <rom>")
1530]
1540NEXT
1550:
1560OSCLI "Save "+n$+" "+STR$÷code%+" "
+STR$÷O%+" "+STR$÷start+" "+STR$÷ld`addr
%
1570:
1580END
1590:
1600DEF FNl(!&70)=?&70
1610DEF FNh(!&70)=?&71
1620DEF FNz(a%)P%=P%+a%:=P%-a%
1630DEF FNerr(err%,err$)[OPT pass%:BRK:
EQUB err%:EQUS err$:EQUB 0:]=pass%