Universal ROM selection code ---------------------------- The Electron hardware selects sideways ROMs with a different I/O location and with a different selection method to other 8-bit Acorn computers. Some systems that the Acorn API has been ported to also use different methods to page in sideways ROMs. This traditionally gives problems trying to write universal code that will run on any system. There is no API call for "page in sideways ROM". However, there is an API call to read from a sideways ROM. This is OSRDRM at &FFB9. This call also has the side-effect that the current ROM - stored in ROMID at &F4 - is paged in when it returns. This is clearly an intended effect. OSRDRM has to remember what the current ROM is before paging it out to read the requested data, and then restore it to return to the caller. However, this has an interesting behaviour. If we set ROMID to a specified ROM number, then on return from OSRDRM it will have been paged in, independently of what hardware method is used on the machine being used. This gives us a very useful machine-independent method to page in a sideways ROM: \ A=ROM to page in STA &F4:JSR &FFB9 \ A,Y corrupted, X=ROM As the call uses the MOS's own code to page in a ROM, it will work on any system that implements the OSRDRM entry, regardless of how the sideways ROM is brought into memory. Any register can be used to store to &F4 before the call, but A and Y are corrupted on return, and X is set to the ROM that has been selected. The call to &FFB9 reads a byte from memory pointed to by ROMPTR at &F6/&F7 with the ROM specified by Y paged in, so you have to be aware of this. The main concern is that if &F6/&F7 points to an I/O location then reading from it may have unintended side effects, so it would be wise to ensure &F7 is set to a value other than &FC/&FD/&FE before calling. The easiest way to do this is for your code to write a safe value to it when it starts.