P725 CEEFAX 725 Wed 2 Mar 21:02/06 |B2201211|a17 .ScR18|i14$JXT|m10|s÷n1÷eM astdring Sidfways 2OM & RAM - Module 18 M Rom Filing System  TRFS able on all BBC microcomputers N opfrating systdm, or laterN The RFS is s dlected by typing ROM red in paged roms or in serially accessf d roms A system. dhf RFS is siHhlar to a  y tape filing system but with thd data s tored in SGR instead NP ograms stored in the RFS can only be run by loading  into the user memory of thf computer. There are two service calls, &0D and &0 E, associated with the RFS. S &0D can bd demonstrated with the servhc e call trace M e 2. DRFSD ) is issued by the MOS when the RFS  ctive and a filing systfm coMdand ha|c
P725 CEEFAX 725 Wed 2 Mar 21:00/00 |B2202211|a17T/SWR18|i14TEXT|m336D|s÷n1÷ es been used. It gives an  opportunity to inform the MOS that it c ontains RFS  of thosf filesN On entry, the Y registe r  e next rom to bf scannedN If  led adfusted rom number is less that the number of the rom  he call sdould bf ignored bfcause it has been NO adjusted rom number for the current  should be stored in &F5, the start addre ss of the RFS data should  he RFS address vector at locations &F6 a nd &F7, and the  set to zero before returning control to the MOS T onsf to service call &0D is summarised n figure 18.1 in which "file" marks the address at which the RFS  start. PHA\ save accumulator CMP
P725 CEEFAX 725 Wed 2 Mar 21:04/00 |B2203211|a17T/SWR18|i10TEXT|m36D8|s÷n1÷ e \ is it sdrvice call &0D?  BNE fourteen \ branch if not & 0D TYA\Y adbusted rom n5Dber EORF \ calculate (15-adbusted rom n5d bdr) CMPF\ e with this rom number BCC \ return if less LDA file MOD 256 \ low byte of first RFS fi le STAF\ RFS vector LDADI\ high bytd of first RFS file STA &F7 \ store in RFS vector  LDA &F4 \ load this rom number EORF\ culate adjusted rom number STA F5 \ and store in &F0  PLA \ balance stac k LDA\ ice provided RTS \ and return to MOS  PLA \ restore accultlator 
P725 CEEFAX 725 Wed 2 Mar 21:04/05 |B2204211 e RTS \ and return t o MOS  FT e call &0D interpreter.  M RFS byte get E initialising the rom  &0DN It is used to retrieve one byte poi ntdd to by RFSA must only res0nnd to this call if the umber stored in &F5 is 11 minus the numb er stored in &F4. T—e byte  qrned in the Y registdr with thd accumul ator reset to RFS ector incremented to point to the next b yte. T gure 18.2 PHA \ save accumulator CMP \ is it service call &0D?  BNE fourteen \ branch if not &0D . N\ sfrvice call &0D goes in here   PLA\
P725 CEEFAX 725 Wed 2 Mar 21:00/07 |B2205211 SGR @XTDAE erestore accumulator LDA \ flag service pro6—ded  RTS \ and return to MOS N fourteen CMP\ it service call &0E? BNE \ branch if not &0E LDA &F5 \ get adjusted rom numbe r EORF\ o currdnt valud CMPF \ compare with this rom's n0mbfr  BNE out \ branch if its a nother rom LDY\ reset Y LDAFY\ d vectored byte TAY \ transfer byte to Y recHster  INC &F6 \ increment low byte of vdctor BNE\ branch if not page boundary INC &F7 \ increment high byte of vector JMP\ exit with A = 0  PLA \ restore accumulator 
P725 CEEFAX 725 Wed 2 Mar 21:00/11 |B2206211|a17T/SgR18|i14TEXT|m41119|s÷n1 ÷e RTS \ and retrun to M OS FTE terpreter.  ures 18.1 and 18.2 will be used in thd i nterprdters  the RFS modules of this course The  rams which illustrate this part of the c ourse qse a modular design  rom header and intdrpreter are created i n a first program  cond program containing the RFS formatti ng  T les from the currdnt filing  ats thdm for the RFS and stores them in memory starting at  created in thd first program ghen all thd RFS rom image is stored on disc or  Dhe program RFSHEAD demonstratds a simp le service rom header and RFS  rN It uses the routines in figures 1|c
P725 CEEFAX 725 Wed 2 Mar 21:12/05 |B2207211 ÷e8.1 and 18.2 to create RFS eter and then chains the program RFSGEN which does the RFSNRFSHEAD tores the address of the first byte avai lable RFS er variable O%. RFSGEN uses the  in O% as the start address for RFS data. TRFSGEN vfry RFS module of this course. I be chained by programs, such as RFSHEAD, which use different  etfrs to achieve different objectives, b ut all the RFS their data in the format created by RFSG EN. TRFSGEN tores data in a block structure  to the format usfd by the tape filing sy stem, with the   The ASCII character "+" (&2B) is usfd a s an end of rom markerN This  nd of data marker and does not mean that files larger than 
P725 CEEFAX 725 Wed 2 Mar 21:12/27 |B2208211|a17T/SWR18|i14 FXTED ÷ered. If, for example, a 30k file is st ored in two  in one rom and terminated with and end o f NT must be in the next rom scanned  RFS and again followed by an end of rom markerN The RFS RFSGE N only formats up to 16k RFS rom imagfs but it  d processor and format 32k RFS rom  s. NT der) is replaced by the "£" (hash)  nuation character (&23) for all except t he first and last blocks. I ion character is used in this way it mea ns that the  previous block, except for the block  mbfr. T ssette hfader block are ssed to store  e address of the bytf after the end of t he file, enabling the RFS  ile searching. TRFS
P725 CEEFAX 725 Wed 2 Mar 21:13/41 |B2209211|a17$^SgR18|i14TEXT|m41B57|s÷n1 ÷eed by RFSGEN must be preceded by a rom header,  e program RFSHEAD. TR FSHEAD and RFSGEN can be ssed with eithe r the disc  ing system to create the RFS rom image. If the DFS is used both these two progra ms and the files to be  on the same discN If thf tape filing sy stem is used  vance the load and execute addresses and  tted. T ssed to create RFS rom images by  mers who have no idea why the programs w ork. Such beginners  .3 and 18.4 helpful. Figure 18.3 shows t he  he DFS and figurf 18.4 sdows the  ograms being used with the tape filing s ystemN In both cases  rmat the supplied program DEMO intn |c
P725 CEEFAX 725 Wed 2 Mar 21:03/13 |B220A211 ÷ean RFS rom  image in a file called TESTN To use the rom FSTSWR d press the Break kfyN Then type NL d press ReturnN If you have used thf DEM O program supplied with  an then either *RUN "DEMO" or CHAIN "DEM O" from the RFS er the I/O processor or a 6502 second  ocessor. BASICDEMO een modified so that it can be *RUNN If you want to know how this was done then disassemble it from &2194 to  hine code embedded in the RKN statement in line 360. CHAINRFSHEADR > SRWSOFTWARE  D Option 0 (off) DL N :0.$ DEMORFSGEN RFSHEAD PRETURN E file name = DEMO E me = SDSTR urn> TESTFFFF
P725 CEEFAX 725 Wed 2 Mar 21:04/37 |B220B211|a17T/SgR18|i14 FXTB ÷e980 16E FURFS formatter with the DFS.  ---------------------------------- C HAIN "RFSHEAD" S L ng RFSHEAD S L ng RFSGENBA PRETURN to end EDEMOR LR E ess = &2194 FD <3fturn> S L DEMO 08 08D2 FFFF1900 FFFF802 E name: STESTR turn> RECORDRETURN DT 0980 FFFF8000 FFFF8000 F Using the RFS formatter with the TFS. ----------M --------------------------- ---------- REMRFSHEAD  MODE7 HIMEMC  MHIMEM HHIMEM F 4 F F  90 FOR pass = 0 TO 2 STEP 2 PD D EM [OPT 
P725 CEEFAX 725 Wed 2 Mar 21:04/59 |B220C211|a17$/SgR18|i14TEXT|m42595|s÷n1 ÷e BRK BRK  BRK JMP  60 OPT FNequb(&82)  OPT FNequb((copyright+diff) MOD 256)  180 BRK OPTFN ("RFS")  B RK OPTFNCG Horsington 1986") BRK  0 .service PHA  CMP £13 BNE  280 TYA EORF  300 CMP romnumber  BCC out LDA f) MOD 256 STA  340 LDA £(lastbyte3diff) DIV 256 STA  LDA romnumbfr EORF 380 STA phrom   0 PLA LDA  RTS   CMP £14 BNE  LDA phrom EOR
P725 CEEFAX 725 Wed 2 Mar 21:00/02 |B220D211 SGR18|i14TEXT|m428FF|s÷n1 ÷e&F CMP  BNE out LDY  0 LDA (rompoint),Y  TAY INC  BNE exit INC t+1 JMP  ut PLA RTS 600 .lastbyte ] NEXT  O%=lastbyte CHAINRFSGEN DE FFNequb(bytf)  P PP +1  DEFFN  00 ?P%=word MOD 256 PDIV 256 PP  DEFF Nequd(double) P P P%S4  DEFFN ) P PPLAN ng$)  REMRFSGEN 20 IFH%<>HIMEM END DIM 0,f—le 20,mcode 50 FFDA  50 osfile=&FFDD FFF  address=&70   3   FALSE 
P725 CEEFAX 725 Wed 2 Mar 21:00/05 |B220E211|a17 ^SR DXTC ÷e 120 A%=0 X Y  disc=USR(osargs)AND &000000FF IF isc=1 OR dIsc=2 disc=FALSE ELSE disc=TRU E FORTOSTEP P code [OPT  LDA £0 STA  STA low TAY  extbyte LDA  EOR (address),Y STA igh LDX   00 LDA hhgh ROLA 320 BCC rotate L DA high EOR  STA high LDA  EOR £&10 STA 390 .rotate ROL  ROL high DEX  0 BNE loop INY  50 CPY last BNE xtbyte RTS ] N EXT IFCAT PRINTP ess to end"' REPEAT 
P725 CEEFAX 725 Wed 2 Mar 21:00/00 |B220F211 SR DXT|m42FD3|s÷n1 ÷e 530 INPUTLINE"Enter file name = "dnam e IFTRUE IF NOT disc P OC IFNO P ROCfile UNTILH OASC ("+") INPUTS name$ IFEND  code="SAVE "+filename$+" "+STR$|÷(HIMEM) +" "+STR$|÷ O% FFFFFFFF 8000" XMOD Y ode DIV 256 OPT CALL li OPT END DEFPROC file OPENUP I Fchannel=0 PRINT"File not found" : C N E £channel : ENDPROC    720 IF disc PROCdisc LEN ame)+23 OMHIMEM name-leN—df,(fsize>256)-3*  512)*(((fsize-1)DIV256)-1) + fsize  IF nextfile > &BFFE PRINT"File too big" : CLOSE£channel ENDPROC  lock=0 IFP OC  PROChfaddr(128,fsize) CLOSE
P725 CEEFAX 725 Wed 2 Mar 21:02/01 |B2210211 SRTEXTB ÷ehannel ENDPOC DEFPOC er(flag,length) LEN 830 ?O%=ASC("*") OO  O%=dnamd OO O 880 O%!1=load O  $ !9=block O O flag O  N—lf+18 O C ALL mcode O OO 20 P OC  ock+1 ENDP OC DEFPOC ngth) J FORITOJ % OIBGET NEXT  070 !address=O%    CALL mcode O  fsize=fsize-length OO 1130 ENDPROC DEFPROC P ROCheader(0,256) IFENDP ROC REPEAT OASC  0 O%=O%+1 POC  k=block+1 UNTIL E NDP2OC DEFPOC IF
P725 CEEFAX 725 Wed 2 Mar 21:02/20 |B2211211^SkR18|i14TEXT|m436A5|s÷n1 ÷enish ENDP2OC IN@UTL = &"l$ EVAL IN PUT"Exec address = &"l$ EVAL "&"+l$) INPUTF 1310 fsize=EVAL("&"+l$) OPT 1330 ENDP OC DEFPOC A 5 XMOD Y k DIV 236 CALL  blocA 0   pblock!10 ENDPROC 