The two programs on this disc are intended to be used to generate a  secure sideways ROM header.  This is then added to a program held on disc and a new file is created with the header and program in an encoded form.  The user must ensure that there is room on the disc for a new file to be created that may use one more sector than the original. 

The ROM image produced may be tested by loading into sideways RAM before blowing into an EPROM and is activated by using the ROM title as an OS (*) command.  This follows the convention of permitting lower case entries and abbreviations down to two characters and a full stop. 

In the version for BASIC programs, the header routine decodes and downloads the original program to the CURRENT setting of PAGE then performs OLD and RUN.

The version for machine code programs, decodes and downloads the code to the load address of the source programs then performs a JSR to the execution address.  A return address and exit is provided to ensure that machine code with an RTS will be handled correctly.

Both routines get all the information they require from the source program so that the user only needs to decide on a suitable ROM title and identify source and destination filenames.  The ROM size is given as either 8k or 16k at the end of each run.  The user is prevented form attempting to generate ROMs over this limit.

Both routines will work with any version of BASIC and on the BBC B, B+, MASTER and TURBO.  Either DFS or ADFS can be the resident filing system.  Only ACORN approved OS calls have been used so the routines should also work on an ECONET system.

Assembled ROMs will work on all machines but not with a second processor active, as the code is always downloaded into the I/O RAM area.



Detailed notes for both programs are as below:


10 - 290
These lines are the initialising.  Note that 'eor' is set to a random number at 100 so that there is no way of knowing the encoding value.


310 - 370
Prints the instructions from DATA


380 - 440
Gets the source filename from the user and opens the source file.  If the file doesn't exist the error is reported.

In the BASIC version, the first byte of the file is fetched and 430 checks to see that it is &0D (the start byte for all BASIC programs).

In the machine code version, 430 finds the load and execution addresses. 


450 - 480
Gets the ROM title from the user. The length is limited to slightly less than one line (40 column).


490 - 530
Gets the destination filename from the user and attempts to OPENUP the file.  If successful then the file already exists and an error is forced.


540 - 800
These set up the esential characters for a sideways ROM as specified by ACORN.


810 - 1240
Identify that a ROM service call has been made.  The service calls accepted by this ROM are:

  3 - Initialise (Print title)
  4 - Unknown command
  9 - Help request  


1250 - 1460 
Compare the command line with the ROM title.


1470 - 1750
Download the program to user RAM.

In the version for BASIC, a call is made to find out where PAGE is (1580).

The machine code version simply downloads to the load address of the source program. 


1760 - 2000
In the BASIC version, the input buffer is flushed (1760) and the characters representing OLD,RUN and VDU6 are put into the input buffer.  At 1940 the ROM number containing BASIC is found.  VDU21 is set at 1950 and a language entry call is made at 1990.

In the machine code version, a call is made to the execution address at 1760.  The remaining code is the return routine.  The call is marked as acknowledged by setting A to zero at 1800.


2010 - 2100
Loads the source file to 'prog' then *SAVES the new file and prints the ROM size.  Note that it is only necessary to enter PROCload on the first pass of the assembler, and the closing message is a forced error to return you to the instructions.


PROCload
Gets bytes from the source file, encodes them by exclusive-or with the value of E% then stores them in memory above the already generated header.  E% is incremented after each byte is encoded.  This makes the encoding less likely to show any detectable pattern. 


PROCerror
A standard error handler.  Print lines ending in '!' are directed here (error 26) along with any errors produced by the DFS.  This ensures that all loose ends are taken care of and the user is always returned to the instructions.


PROCclear
Clears the area of memory to be used for the ROM.  &FF is used as this is the most efficient value to have as blank code.  Most EPROM programmers ignore this value, so programming faster.  A simple piece of co