Mastering Sideways ROM & RAM - Module 22 - RFS cartridges --------------------------------------------------------- The RFS language ROM introduced in Module 21 can be modified to auto-boot from any ROM socket. The method used to achieve this uses an "illegal" interception of service call. In spite of this it can be quite a useful modification to make to the RFS service call interpreter for software stored in ROM cartridges. A ROM cartridge formatted with the program AUTORFS will always boot itself when the Break key is pressed. Language ROMs in low priority sockets are usually entered by typing a * command which is compared with the ROM's title string and the ROM is selected with Osbyte &8E when a match is found (see Module 17). The service call interpreter in the program AUTORFS does not intercept service call 4 to select the language in this way. Instead it intercepts service call &FE as shown in figure 22.1. If you have been following the course you will know that service call &FE is issued by the MOS on both hard and soft reset and can be intercepted for illegal purposes as long as the registers are restored after the illegal activity (see module 12). .service PHA \ store accumulator CMP #&FE \ is this service call &FE? BNE trythirteen \ if not branch to RFS interpreter TXA PHA \ store X TYA PHA \ store Y LDA #&FC \ Osbyte &FC LDX &F4 \ load X with this ROM number LDY #0 \ and make this ROM number JSR &FFF4 \ the current language after reset PLA \ pull Y TAY \ restore Y PLA \ pull X TAX \ restore X PLA \ retore A RTS \ and return .trythirteen Figure 22.1 Intercepting service call &FE. ----------- ------------------------------ The ROM interpreter intercepts service call &FE and uses Osbyte &FC to write the number of the ROM to be entered following a soft reset (Break). Using Osbyte &FC in this way stores the number of the ROM cartridge in location &28C. The ROM whose number is stored in this location is entered following a soft reset or a BRK (error). The RFS ROM cartridge will be entered after pressing the Break key as long as BASIC is the highest priority language. When you write programs to be stored in RFS ROM cartridges there is no need to trap the Break key because AUTORFS will do this for you. If the AUTORFS ROM image is installed in socket &0F and the programs stored in the RFS disable the Escape key then it is difficult to stop the software running. Pressing Break, Ctrl+Break and Shift+Break will all boot the RFS software. Shift+Break will attempt to boot a disc but the ROM will still boot afterwards. Software formatted in this way can be permanently installed in socket &0F of a computer which is dedicated to a well defined task such as controling laboratory equipment. The software must be installed in a higher numbered socket than the DNFS on a BBC or B+ which contains the Tube interface code, or service all &FE will not be seen. The program AUTORFS must be used with the formatting program RFSGEN and whatever programs you want to store in the RFS. These programs are used to create the RFS ROM image and detailed instructions on using them were included in Module 18. AUTORFS was written to be used with the supplied demonstration program DEMO. If you want to use it with any other program you will need to alter the command string in lines 1160 to 1180. 10 REM: AUTORFS 20 MODE7 30 HIMEM=&3C00 40 diff=&8000-HIMEM 50 H%=HIMEM 60 ROMnumber=&F4 70 phROM=&F5 80 ROMpoint=&F6 90 breakv=&202 100 osbyte=&FFF4 110 FOR pass = 0 TO 2 STEP 2 120 P%=HIMEM 130 [ OPT pass 140 JMP language+diff 150 JMP service+diff 160 OPT FNequb(&C2) 170 OPT FNequb((copyright+diff) MOD 256) 180 BRK 190 OPT FNequs("AUTORFS") 200 .copyright 210 BRK 220 OPT FNequs("(C)1987 Gordon Horsington") 230 BRK 240 .service 250 PHA 260 CMP #&FE 270 BNE trythirteen 280 TXA 290 PHA 300 TYA 310 PHA 320 LDA #&FC 330 LDX ROMnumber 340 LDY #0 350 JSR osbyte 360 PLA 370 TAY 380 PLA 390 TAX 400 PLA 410 RTS 420 .trythirteen 430 CMP #13 440 BNE fourteen 450 TYA 460 EOR #&F 470 CMP ROMnumber 480 BCC out 490 LDA #(lastbyte+diff) MOD 256 500 STA ROMpoint 510 LDA #(lastbyte+diff) DIV 256 520 STA ROMpoint+1 530 LDA ROMnumber 540 EOR #&F 550 STA phROM 560 .exit 570 PLA 580 LDA #0 590 RTS 600 .fourteen 610 CMP #14 620 BNE out 630 LDA phROM 640 EOR #&F 650 CMP ROMnumber 660 BNE out 670 LDY #0 680 LDA (ROMpoint),Y 690 TAY 700 INC ROMpoint 710 BNE exit 720 INC ROMpoint+1 730 JMP exit+diff 740 .out 750 PLA 760 RTS 770 .language 780 CLI \ Enable interupt requests 790 LDX #&FF 800 TXS \ Reset stack 810 LDA #(basic+diff) MOD 256 820 STA breakv 830 LDA #(basic+diff) DIV 256 840 STA breakv+1 850 LDA #&8D 860 JSR osbyte \ *ROM 870 LDA #&8B 880 LDX #1 890 LDY #0 900 JSR osbyte \ *OPT1,0 910 LDA #&0F 920 LDX #0 930 JSR osbyte \ Flush all buffers 940 LDA #&FF 950 PHA 960 .keyboard 970 PLA 980 TAX 990 INX 1000 TXA 1010 PHA 1020 LDY rfscomm+diff,X 1030 BEQ basic 1040 LDA #&8A 1050 LDX #0 1060 JSR osbyte 1070 JMP keyboard+diff 1080 .basic 1090 LDA #&BB 1100 LDX #0 1110 LDY #&FF 1120 JSR osbyte \ Find BASIC 1130 LDA #&8E 1140 JMP osbyte \ Enter BASIC 1150 .rfscomm 1160 OPT FNequs("CHAIN""DEMO""") 1170 OPT FNequb(&0D) 1180 BRK 1190 .lastbyte 1200 ] 1210 NEXT 1220 O%=lastbyte 1230 CHAIN"RFSGEN" 1240 DEFFNequb(byte) 1250 ?P%=byte 1260 P%=P%+1 1270 =pass 1280 DEFFNequw(word) 1290 ?P%=word 1300 P%?1=word DIV 256 1310 P%=P%+2 1320 =pass 1330 DEFFNequd(double) 1340 !P%=double 1350 P%=P%+4 1360 =pass 1370 DEFFNequs(string$) 1380 $P%=string$ 1390 P%=P%+LEN(string$) 1400 =pass