Joining ROM images together |
MDFS::Info.Comp.BBC.SROMs.JoinROM/htm | Search |
To do this, you need the image of the ROM you are adding to, and the source code (or a method of relocating the image) for the ROM code you want to add. This is done by changing the destination of the service call entry at &8003 to the start of the spare space at the end of the ROM. At the start of this spare space, the new code firstly calls the old service handler, and then continues with the new code's service handler:
8003 JMP SERV -> 8003 JMP MYCODE ... SERV \ Service handler ... MYCODE JSR SERV ... \ My service handlerThe additional code can even be a relocated ROM image with the language entry point in the first three bytes changed to the JSR SERV instruction. The following instruction will then be the relocated jump to the additional service handler.
Any number of ROM code fragments can be joined together like this. However, as each fragment is independent of each other, only one can claim workspace and use the workspace byte at &DF0+rom, and only one can be a language and be entered at &8000. To be entered as a language, the entry at &8000 should be changed to jump to the ROM code fragment's entry point:
8000 BRK:BRK:BRK -> 8000 JMP MYLANG 8003 JMP SERV -> 8003 JMP MYCODE ... SERV \ Service handler -> SERV ... MYCODE JSR SERV ... \ My service handler MYLANG \ My language startupROMMouse shows how to add extra ROM code by adding a mouse driver to a ROM image.