114. Another relocate program ~~~~~~~~~~~~~~~~~~~~~~~~ Earlier, I gave a Procedure for tacking onto the end of a Basic program, so that long programs could be run off disc, with a PAGE value down to &E00. This works fine, but there are times when this is not convenient. If you are adapting a very long and complex program from cassette to disc, it may not be safe to go tacking procedures on the end. This is especially true if there is data after the visible Basic part of the program, as any additions are likely to overwrite it. A typical example would be a text adventure game like Castle of Riddles, which is 65 blocks long, over half of which is data. This is too long to even LOAD into memory with PAGE set at &1900. The solution is to make the program a 2-part one, with the relocate routine in the 1st half, thus avoiding any need to tamper with the main program. If the program is short enough to run with PAGE at &1100, then the 1st program need consist only of one line, ie 10 PAGE=&1100:CHAIN "Dragon2" . If the program must run with PAGE lower than that, eg &E00, then the program below will do the trick. It is so fast that it doesn't bother to work out the length of the program, (tricky if you have to allow for any hidden data), but simply relocates all available memory in 1/3 second. In line 10 you specify the new value of PAGE, eg &E00, and the name of the main program. You could of course replace the final term with an INPUT N$ statement, in which case the one relocator will run any named program. PAGE is initially set to &1100 in line 10, in case the main program is too long to even LOAD with PAGE at &1900. This doesn't affect the relocator itself, which churns on merrily, blissfully unaware that PAGE has been altered, but it does define where the main program will LOAD. In many cases, this 1st term in line 10 can be omitted, but it doesn't do any harm to leave it in, (with the Acorn 8271 DFS's at any rate). The program may already have a first part, which just sets up some of the character shapes, and displays a logo on the screen. You could easily add this routine in place of the CHAIN "Dragon2" type of command, followed by END if necessary. Ignore any corruption of the logo; if you're clever enough, you'll know how to preserve it! This program looks rather weird, and it can be hard to spot mistakes. Try missing out the VDU21 in line 60 at first, otherwise useful error messages are suppressed. 10 PAGE=&1100:D%=&E00:N$="Dragon2" 20 !&70=D%:!&72=PAGE:!&74=HIMEM-PAGE 30 P%=&76:[OPT2:LDX&74:LDY#0 40 LDA(&72),Y:STA(&70),Y:INY:BNE&85:INC&71:INC&73 50 DEX:BNE&7A:DEC&75:BNE&7A:RTS:] 60 VDU21:*KEY9LOADN$|M*TAPE|MCALL&76|MPAGE=D%|MNEW|MOLD|MRUN|F|M 70 *FX138,0,137