Mastering Sideways ROM & RAM - Module 23 - RFS for BASIC programmers -------------------------------------------------------------------- The RFS modules of the course have hopefully been useful to both BASIC and Assembly language programmers. Experienced Assembly language programmers will be able to combine the different ideas illustrated in the course modules into one "ideal" RFS service call interpreter. This might be more difficult for BASIC programmers who simply want to use the RFS formatting programs without necessarily knowing how to modify the Assembly language instructions to suit their particular needs. This module will be of particular interest to BASIC programmers who do not understand Assembly language. I will provide an RFS interpreter which includes most of the relevant ideas in one program and discuss some simple modifications which can easily be made to customise the program. The program ALLRFS is used with RFSGEN to create an RFS ROM image which incorporates extended help, auto-boot and running a BASIC file stored in the RFS with a new * command. The ROM image created with this program only needs to be used in one SWR bank or in one epROM. If more than one RAM bank is used to store RFS files then all but one ROM image should be created with RFSHEAD (introduced in module 18). I will not go over the instructions for using these formatting programs again. If you do not know how to use the formatting programs go back to module 18 where detailed instructions were given. The RFS will be selected and catalogued when either R+Break or Ctrl+R+Break is pressed on the BBC B or when Ctrl+R+Break is used on the BBC Master. The ROM image created with ALLRFS responds to the *HELP command by printing: ROM Filing System RFS and to *HELP RFS by printing: ROM Filing System Select RFS with *ROM Boot RFS with Ctrl+R+Break Enter RFS with *RFS or *FX142,n This response to the *HELP command can be modified in lines 1600 to 1790 of ALLRFS. The argument used to request extended help is in line 1660. If, for example, you want to request extended help with *HELP FILES then modify line 1660 to read: 1660 OPT FNequs("FILES") The extended help message is in lines 1700 to 1780. Each line of text should be preceded by and followed by a carriage return character (lines 1700, 1720, 1740, 1760, 1780) and the last character of the message must be followed by the BRK instruction (line 1790). You can use up to 255 characters in the extended help message. If, for example, you want to alter the heading of the extended help from "ROM Filing System" to "RFS BASIC programs" then change line 1710 to read: 1710 OPT FNequs("RFS BASIC programs") If you do not want any heading to the extended help message then delete lines 1710 and 1720. One BASIC program stored in the RFS can be chained into user memory with a new * command. ALLRFS uses the command *RFS to chain the program DEMO. You can alter the string used for the new * command in line 270 and alter the BASIC command in line 3010. If, for example, you want to chain a menu program called STARTUP with the new command *MENU then alter line 270 to read: 270 OPT FNequs("MENU") alter line 1770 to read: 1770 OPT FNequs("Enter RFS with *MENU or *FX142,n") and alter line 3010 to read: 3010 OPT FNequs("CHAIN""STARTUP""") The program STARTUP must be stored in an active RFS ROM image in the computer but it does not have to be in the ROM image created by ALLRFS. If the ROM image created with ALLRFS is stored in an epROM in socket &0F then the menu program will always run when the computer is switched on and when Ctrl+Break is pressed. 10 REM: ALLRFS 20 MODE7 30 HIMEM=&3C00 40 diff=&8000-HIMEM 50 H%=HIMEM 60 address=&A8 70 comvec=&F2 80 ROMnumber=&F4 90 phROM=&F5 100 ROMpoint=&F6 110 breakv=&202 120 gsinit=&FFC2 130 gsread=&FFC5 140 osasci=&FFE3 150 osnewl=&FFE7 160 osbyte=&FFF4 170 oscli=&FFF7 180 FOR pass = 0 TO 2 STEP 2 190 P%=HIMEM 200 [ OPT pass 210 JMP language+diff 220 JMP service+diff 230 OPT FNequb(&C2) 240 OPT FNequb((copyright+diff) MOD 256) 250 BRK 260 .title 270 OPT FNequs("RFS") 280 .copyright 290 BRK 300 OPT FNequs("(C)1987 Gordon Horsington") 310 BRK 320 .service 330 PHA 340 CMP #4 350 BNE trythirteen 360 TXA 370 PHA 380 TYA 390 PHA 400 LDX #&FF 410 .comloop 420 INX 430 LDA title+diff,X 440 BEQ found 450 LDA (comvec),Y 460 INY 470 CMP #ASC(".") 480 BEQ found 490 AND #&DF 500 CMP title+diff,X 510 BEQ comloop 520 PLA 530 TAY 540 PLA 550 TAX 560 PLA 570 RTS 580 .found 590 LDA #&8E 600 LDX ROMnumber 610 JMP osbyte \ Enter this ROM 620 .trythirteen 630 CMP #13 640 BNE fourteen 650 TYA 660 EOR #&F 670 CMP ROMnumber 680 BCC out 690 LDA #(lastbyte+diff) MOD 256 700 STA ROMpoint 710 LDA #(lastbyte+diff) DIV 256 720 STA ROMpoint+1 730 LDA ROMnumber 740 EOR #&F 750 STA phROM 760 .exit 770 PLA 780 LDA #0 790 RTS 800 .fourteen 810 CMP #14 820 BNE trythree 830 LDA phROM 840 EOR #&F 850 CMP ROMnumber 860 BNE out 870 LDY #0 880 LDA (ROMpoint),Y 890 TAY 900 INC ROMpoint 910 BNE exit 920 INC ROMpoint+1 930 JMP exit+diff 940 .out 950 PLA 960 RTS 970 .trythree 980 CMP #3 990 BNE trynine 1000 JMP three+diff 1010 .trynine 1020 CMP #9 1030 BNE out 1040 TXA 1050 PHA 1060 TYA 1070 PHA 1080 LDA address 1090 PHA 1100 LDA address+1 1110 PHA 1120 SEC 1130 JSR gsinit 1140 LDX #0 1150 JSR gsread 1160 BCC tryextended 1170 LDX #(helptitle+diff) MOD 256 1180 LDY #(helptitle+diff) DIV 256 1190 JSR print+diff 1200 .exithelp 1210 PLA 1220 STA address+1 1230 PLA 1240 STA address 1250 PLA 1260 TAY 1270 PLA 1280 TAX 1290 PLA 1300 RTS 1310 .helploop 1320 INX 1330 JSR gsread 1340 .tryextended 1350 CMP #ASC(".") 1360 BEQ extension 1370 AND #&DF 1380 CMP extended+diff,X 1390 BEQ helploop 1400 LDA extended+diff,X 1410 BPL exithelp 1420 .extension 1430 LDX #(exthelp+diff) MOD 256 1440 LDY #(exthelp+diff) DIV 256 1450 JSR print+diff 1460 BEQ exithelp 1470 .print 1480 STX address 1490 STY address+1 1500 LDY #&FF 1510 .printloop 1520 INY 1530 LDA (address),Y 1540 BEQ endprint 1550 BMI printloop 1560 JSR osasci 1570 JMP printloop+diff 1580 .endprint 1590 RTS 1600 .helptitle 1610 OPT FNequb(&0D) 1620 OPT FNequs("ROM Filing System") 1630 OPT FNequb(&0D) 1640 OPT FNequw(&2020) 1650 .extended 1660 OPT FNequs("RFS") 1670 OPT FNequw(&0DFF) 1680 BRK 1690 .exthelp 1700 OPT FNequb(&0D) 1710 OPT FNequs("ROM Filing System") 1720 OPT FNequw(&0D0D) 1730 OPT FNequs("Select RFS with *ROM") 1740 OPT FNequb(&0D) 1750 OPT FNequs("Boot RFS with Ctrl+R+Break") 1760 OPT FNequb(&0D) 1770 OPT FNequs("Enter RFS with *RFS or *FX142,n") 1780 OPT FNequb(&0D) 1790 BRK 1800 .three 1810 TXA 1820 PHA 1830 TYA 1840 PHA 1850 LDA #&7A 1860 JSR osbyte 1870 CPX #&33 \ Is it Ctrl+R+Break? 1880 BEQ rbreak 1890 PLA 1900 TAY 1910 PLA 1920 TAX 1930 PLA 1940 RTS 1950 .rbreak 1960 LDA #&C9 1970 LDX #1 1980 LDY #0 1990 JSR osbyte \ Disable keyboard 2000 LDA #&0F 2010 LDX #0 2020 JSR osbyte \ Flush all buffers 2030 LDA address 2040 PHA 2050 LDA address+1 2060 PHA 2070 LDX #(rfs+diff) MOD 256 2080 LDY #(rfs+diff) DIV 256 2090 JSR print+diff 2100 LDX #(cat+diff) MOD 256 2110 LDY #(cat+diff) DIV 256 2120 JSR print+diff 2130 LDA #&8D 2140 JSR osbyte \ Select RFS 2150 LDA #&8B 2160 LDX #1 2170 LDY #2 2180 JSR osbyte \ *OPT1,2 2190 LDX #(dot+diff) MOD 256 2200 LDY #(dot+diff) DIV 256 2210 JSR oscli \ Catalogue RFS 2220 LDA #&8B 2230 LDX #0 2240 LDY #0 2250 JSR osbyte \ *OPT 1,0 2260 JSR osnewl 2270 LDX #(rfs+diff) MOD 256 2280 LDY #(rfs+diff) DIV 256 2290 JSR print+diff 2300 LDX #(act+diff) MOD 256 2310 LDY #(act+diff) DIV 256 2320 JSR print+diff 2330 PLA 2340 STA address+1 2350 PLA 2360 STA address 2370 LDA #&C9 2380 LDX #0 2390 LDY #0 2400 JSR osbyte \ Enable keyboard 2410 PLA 2420 PLA 2430 PLA 2440 LDA #0 2450 RTS 2460 .dot 2470 OPT FNequs("CAT") 2480 OPT FNequb(&0D) 2490 .rfs 2500 OPT FNequs("ROM Filing System ") 2510 BRK 2520 .cat 2530 OPT FNequs("Catalogue") 2540 OPT FNequb(&0D) 2550 BRK 2560 .act 2570 OPT FNequs("active") 2580 OPT FNequw(&0D0D) 2590 BRK 2600 .language 2610 CLI \ Enable interupt requests 2620 LDX #&FF 2630 TXS \ Reset stack 2640 LDA #(basic+diff) MOD 256 2650 STA breakv 2660 LDA #(basic+diff) DIV 256 2670 STA breakv+1 2680 LDA #&8D 2690 JSR osbyte \ *ROM 2700 LDA #&8B 2710 LDX #1 2720 LDY #0 2730 JSR osbyte \ *OPT1,0 2740 LDA #&0F 2750 LDX #0 2760 JSR osbyte \ Flush all buffers 2770 LDA #&FF 2780 PHA 2790 .keyboard 2800 PLA 2810 TAX 2820 INX 2830 TXA 2840 PHA 2850 LDY rfscomm+diff,X 2860 BEQ endkey 2870 LDA #&8A 2880 LDX #0 2890 JSR osbyte 2900 JMP keyboard+diff 2910 .endkey 2920 PLA 2930 .basic 2940 LDA #&BB 2950 LDX #0 2960 LDY #&FF 2970 JSR osbyte \ Find BASIC 2980 LDA #&8E 2990 JMP osbyte \ Enter BASIC 3000 .rfscomm 3010 OPT FNequs("CHAIN""DEMO""") 3020 OPT FNequb(&0D) 3030 BRK 3040 .lastbyte 3050 ] 3060 NEXT 3070 O%=lastbyte 3080 CHAIN"RFSGEN" 3090 DEFFNequb(byte) 3100 ?P%=byte 3110 P%=P%+1 3120 =pass 3130 DEFFNequw(word) 3140 ?P%=word 3150 P%?1=word DIV 256 3160 P%=P%+2 3170 =pass 3180 DEFFNequd(double) 3190 !P%=double 3200 P%=P%+4 3210 =pass 3220 DEFFNequs(string$) 3230 $P%=string$ 3240 P%=P%+LEN(string$) 3250 =pass